Skip to main content
Marschland Media & Arts
Participant
January 30, 2019
Answered

Is there an eventListener available when an object gets selected/deselected?

Hi,

I just started with scripting and was able to build a panel that uses a .jsx to evaluate shapes and returns the results to the HTML. But for each result I would have to use a button in the HTML to fire the .jsx-function.

<a href="#" onClick="update()" id="refresh"><img src="../img/RefreshDark.svg"></a>

So update() fires a function in ExtendedScript via csInterface.evalScript(). So far so good, everything works as expected.

What I need now is firing this function in JSX whenever I select or deselect an object (path/group/compound). The eventListeners I found so far are not capable of tracking selections as far as I understand. Is there a way to imitate such a behavior as for example the info panel? Whenever I select an object it instantly updates position and size of said object. How can this be achieved for my own panel without having to click a button/link?

Thank you in advance, especially for all the old threads and tutorials you guys created on several personal sites.

This topic is closed to new replies. Start a new post to keep the conversation going.
CarlosCanto
CarlosCantoCorrect answer
Community Expert
January 31, 2019

6 replies

Inspiring
February 18, 2022

Yes there is, i using 

afterSelectionChanged
 
app.addEventListener("afterSelectionChanged", function(evt){
if(app.selection[0] !== undefined){
var thePageItem = app.selection[0];
// DO THE THING
}
});
Translate
Ten A
Community Expert
Community Expert
January 31, 2019

This thread moved from Illustrator Scripting to Extensions / Add-ons Development and...

You can reference events in Illustrator CC SDK->Marked Object sample plugin project.

Check below page...

Adobe Illustrator CC SDK for plugins and extensions | Adobe I/O

Translate
Marschland Media & Arts
Participant
January 31, 2019

Ten, thank you for the info and link. I briefly checked it before and now I took a closer look. Unfortunately this is too complicated for me right now. I just filled my head with all the new "make a panel" information and the SDK way seems to be too steep of a learning curve for me right now. Maybe I'll tackle this one with the next extension but for now I am happy the AiHostAdapter got me to where the extension needed to be.

Translate
Trevor:
Legend
January 31, 2019

Some more links!

https://medium.com/adobetech/how-to-package-distribute-and-install-your-creative-cloud-extension-8eec6da31009

Getting-Started-guides/Package Distribute Install at master · Adobe-CEP/Getting-Started-guides · GitHub

GitHub - Adobe-CEP/Getting-Started-guides: Getting Started guides and samples for CEP extensions

Enjoy.

Take into account that the plugin might already exist in the users plugins folder from another extension.

If you could post how you deal with the hybrid it could be useful.

Thanks

Translate
CarlosCanto
Community Expert
CarlosCantoCommunity ExpertCorrect answer
Community Expert
January 31, 2019
Marschland Media & Arts
Participant
January 31, 2019

Thank you Carlos for your input. I already read all of those topics multiple times but I was hoping to get around using any plug-ins. I now used the AiHostAdapter and it works like a charm, so I now need to figure out how to create a hybrid extension that deploys the plug-in along with the panel.

Translate