• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Detecting a DropDownList selection

Participant ,
Apr 24, 2019 Apr 24, 2019

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`?

TOPICS
Scripting

Views

1.3K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 25, 2019 Apr 25, 2019

Copy link to clipboard

Copied

Hi Kals ,

don't know if that will help, but it may be worth a try:

Re: ScriptUI Custom Events

Regards,
Uwe

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 25, 2019 Apr 25, 2019

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 25, 2019 Apr 25, 2019

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 25, 2019 Apr 25, 2019

Copy link to clipboard

Copied

LATEST

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:

  1. Just use the `onChange` or `change` event (ignoring the actual problem)
  2. Here's my dirty hack that forces the value to change (to some invisible option) so we can use the `onChange` or `change` event
  3. Some other 'solution' that fails in practice (I tested in web browsers and InDesign).

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines