Copy link to clipboard
Copied
I would like to detect when the user selects an item (any item) from a DropDownList. The `onChange` event isn't quite what I'm after, as it's only called if the value changes—I want to detect any selection, even if it's the status quo. `onActivate` isn't what I want either, as this is called the moment the user clicks on the control, before they've selected anything.
In CS6, I could detect a selection using `onClick`, which (ironically) was called after the user chose one of the items in the drop-down, not when they actually clicked on the control. This worked in CS6, even though the docs don't list `onClick` as a method of DropDownList, however it no longer works in InDesign CC.
Is there any way to replicate this behaviour in CC, or am I stuck with choosing between `onActivate` and `onChange`?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Thanks Uwe. I'm not at all familiar with writing custom events, so I wonder if it might be a bit beyond me. Your answer does seem to confirm that there isn't a simple solution… ah well.
Copy link to clipboard
Copied
First read into this here by Marc Autret:
Indiscripts :: Note on ScriptUI Mouse Events
Then check this sample by Davide Barranca:
https://www.davidebarranca.com/2013/08/extendscript-scriptui-events-call-notify-dispatchevent/
No drop down list selection sample, but you may get the idea to implement your own handler.
Regards,
Uwe
Copy link to clipboard
Copied
Thanks again Uwe. After digging around a bit, I've concluded that this limitation extends to JavaScript itself, where there simply isn't any reliable way to determine when a ListItem (or HTML option element) has been clicked (without changing the selection). I must have found close to a dozen questions on Stack Exchange which were all variations on this theme. The answers fell into three broad categories:
Meanwhile, I've come up with a workaround in my app that comes close to the desired behaviour, and am moving on to the next thing. Thanks again for taking the time to respond.