3 Replies Latest reply on Aug 6, 2013 7:45 AM by mrfale67

    Listbox multiple selection & realtime script execution

    mrfale67 Level 2

      Hi All,

      I have been scripting 2-million lines to have an equivalent field.currentValueIndices where field is a listbox which allows multiple selection.

      In fact, field.currentValueIndices can't work because

      1) I can't tick "Immediately set value" checkbox because I need multiple selection;

      2) I'd like to catch a keystroke-like event i.e. I would like to launch a script as soon as the user selects on one or more of the listbox values (what I also call "realtime script execution");


      Now, it seems that Abobe JS API provides all methods and properties needed to self-write a quite complicated script to achieve this. I am speaking of "event.change", "event.modifier", "event.shift", ecc...

      However, as said, this is a quite complicated task and I would like to make sure I am not missing something.

      For example, is there no way to dispatch a commit event once the mouse is down/up on the listbox so that I can retrieve the old easy field.currentValueIndices property? I see event.rc but it doesn't seem to work. I even tried event.selStart / selEnd but it seems they apply to text fields only.

      Thanks for your assistance.

        • 1. Re: Listbox multiple selection & realtime script execution
          try67 MVP & Adobe Community Professional

          Maybe you can try to explain what it is you're trying to achieve, exactly, with this script.


          And I hope the 2-million lines of codes was a joke...

          • 2. Re: Listbox multiple selection & realtime script execution
            mrfale67 Level 2

            Hi Gilad,

            as said, I have a ListBox with several values in it.

            When clicking on one of these values, I'd like other fields to populate accordingly.

            Say user selects value A from the ListBox, then a textfield will show a text referring to A.

            If user selects more values from the ListBox (through Ctr, Shift or mouse dragging), then that textfield will immediately show a different text message and so on.


            To let you better understand:

            the easiest solution I tried was to add a mouse-up event action in the ListBox to .setFocus on a dummy field of the doc. This way I hoped, the ListBox would commit and I could use .currentValueIndices to get its selected values. However, it seems that there are no ways to make the ListBox commit unless the user clicks somewhere else on the doc.


            PS: by scripting with event.shift, event.modifier and event.change I got to a good point (just about 50 lines of code actually - if you wish I can send them over to you privately). However, I can't capture mouse dragging because "event" doesn't have that property;

            • 3. Re: Listbox multiple selection & realtime script execution
              mrfale67 Level 2

              I found it Gilad!

              For others' reference (I hope Adobe people will leave this nice hack I found today after hours of hassle - well, on the contrary, let's hope they will add a field commit() method or similar):


              this is how I made my "f" field commit without user's intervention:


              f.display = display.hidden;

              f.display = display.visible;


              as previously said, .setFocus() doesn't reach the same effect.

              Maybe you Gilad or someone else have a more elegant solution? Please share it with us.