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

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

  • January 30, 2019
  • 3 replies
  • 1508 views

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 has been closed for replies.
Correct answer CarlosCanto

you might be able to add more events, try to find AIHostAdapter plugin

here are some helpful links

Re: afterSelectionChanged & afterSelectionAttributeChanged events in Illustrator

Re: Eventlistener for edit text in illustrator

Re: Event listener when TextFrameItem is edited

3 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
}
});
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

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.

Trevor:
Legend
January 31, 2019
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.