Copy link to clipboard
Copied
Hi,
I'm trying to register an event handler for `selectionsChanged` event.
main.js has
csInterface.evalScript('init()');
index.jsx has
function handleSelection(event) {
if((event.type == 'selectionsChanged') && (event.object instanceof Thumbnail)) {
alert("selections changed!");
return {handled:false};
}
}
function init() {
app.eventHandlers.push( {handler: handleSelection} );
}
but the handler is never run. Why does this not work with CEP extension?
Thanks!
Copy link to clipboard
Copied
if(event.object instanceof Document && event.type == 'selectionsChanged')
Copy link to clipboard
Copied
Thanks for answer. You are right, it should be Document, but even if I remove the whole if-clause, it is never run. It seems to work only in start-up scripts but not CEP extensions? How to do it in extensions? Do I have to make a start-up script AND extension?
Copy link to clipboard
Copied
I wish I had the answer, but I'm still learning CEP extensions.
The answer might be found in this Custom Metadata Panel which displays metadata when thumbnail selections are changed.
You can get the source code at
com.adobe.custom-metadata-cep.1.3.0.zxp
Or, install the extension and view the files in \CEP\extensions\com.adobe.custom-metadata-cep\
See selectEvent in this file: host\startupSelection.jsx
See SelectEventPlugin (as well as several other Events) in this file: \index.js
Copy link to clipboard
Copied
Thanks alot, that is actually very useful resource to look at for my project!!
It seems they also use a separate startup-script to catch the native event and forward it to the extension. I don't like this approach but since that is made by Adobe (?) it must be the right way. As a newbie I would just like to know why it is like that, and what is the right way to distribute such thing...