7 Replies Latest reply on Jun 9, 2017 7:26 AM by Laubender

    Keydown to apply UI Dialog button

    JustOneBren Level 1

      Hi all, hopefully someone will be able to help.

       

      This is a snippet from a script I have used for a while but has now stopped working as I have stepped up to CC 2017 from CS6.

      I used to be able to press 'l' to select the 'Lock' button, 'u' to select the 'Unlock' button but these no longer work.

      I have looked for solutions but to no avail, can anyone let me know what has changed and how to fix the problem.

       

      Thanks in advance, Bren

       

       

      // UI Dialog options

      win = new Window('dialog', 'PAGE HEADERS');

       

       

      win.btn0 = win.add('button', undefined, 'LOCK \'L\'   ')

                      win.btn0.onClick = function() {win.close(0)}

                      win.addEventListener ( 'keydown', onKeyPress0 )

                      function onKeyPress0 (evt) { if (evt.keyName=="H") { win.close(0) }}

       

       

      win.btn1 = win.add('button', undefined, 'UNLOCK \'U\' ')

                      win.btn1.onClick = function() {win.close(1)}

                      win.addEventListener ( 'keydown', onKeyPress1 )

                      function onKeyPress1 (evt) { if (evt.keyName=="U") { win.close(1) }}

                    

      win.btn2 = win.add('button', undefined, 'CANCEL \'Esc\'')

                      win.cancelElement = win.btn2

       

       

      win.center()

      var myDlg = win.show()

        • 1. Re: Keydown to apply UI Dialog button
          Laubender Adobe Community Professional & MVP

          Hi Bren,

          just tested your script with InDesign CS6 v 8.1.0 and CC v 9.3.0 on Mac OS X 10.6.8.

           

          InDesign CS6 v 8.1.0 : All is working as expected.

          InDesign CC v 9.3.0 : No way. The event did not fire or the listener cannot listen.

           

          I suspect a bug in CC and above.

           

          Regards,
          Uwe

          1 person found this helpful
          • 2. Re: Keydown to apply UI Dialog button
            JustOneBren Level 1

            Thanks Uwe, I will have to start moving and clicking the mouse again

             

            I might report it on the 'Adobe Bug Report Form' but it may it be too small fry for them to worry about.

            • 3. Re: Keydown to apply UI Dialog button
              Laubender Adobe Community Professional & MVP

              Hi Bren,

              also did a little experiment where I included an edittext field that is active and not visible.

              In this case the keyboard events can be detected.

               

              That's no valid workaround, because this would only work as long as the invisible edittext field is active.

              ( It will not be active anymore if the user clicks in the gray area of the main ScriptUI window. )

               

              All tests currently done on OS X 10.6.8.

               

              Regards,
              Uwe

              • 4. Re: Keydown to apply UI Dialog button
                Laubender Adobe Community Professional & MVP

                Sorry.
                I should have added, that I did this experiment (mis)using an edittext field with a "palette" type of window.
                And not with a "dialog" one.

                 

                Regards,
                Uwe

                • 5. Re: Keydown to apply UI Dialog button
                  Loic.Aigon Adobe Community Professional

                  which I did with no more success. Ahhh ScriptUI

                  • 6. Re: Keydown to apply UI Dialog button
                    Peter Kahrel Adobe Community Professional & MVP

                    > I might report it on the 'Adobe Bug Report Form' but it may it be too small fry for them to worry about.

                     

                    Do report it. It's not small fry. Any bug is a bug. If Adobe aren't told about these things, nothing happens. The more people complain the better.

                    • 7. Re: Keydown to apply UI Dialog button
                      Laubender Adobe Community Professional & MVP

                      FWIW:

                      This issue is not only with "keydown", it's also with "keyup".


                      In the meanwhile I also tested with window type "window":

                      Same problems.


                      "panel" and "window" type ScriptUI windows in CC v 9.3.0 with an edittext field, visible or invisible:

                      If the listening mechanism stops it helps to switch to a different app and coming back to InDesign. As soon as the window gets focus and is active the listeners for "keydown" and "keyup" are working again. Event target is [object Edittext].

                       

                      "palette" type ScriptUI windows in CC v 9.3.0 with an edittext field, visible or invisible:
                      If the listening mechanism stops I can get back access to the listening mechanism after clicking somewhere else out of the ScriptUI window and to click the title bar of the ScriptUI window. I do not have to switch to a different app. Event target is [object Edittext].

                       

                      So having an edittext field somewhere in the window could be a "little workaround".

                       

                      Regards,
                      Uwe

                       

                      // EDITED