6 Replies Latest reply on Oct 1, 2014 5:16 PM by keywords

    Capturing escape key for custom dialog

    Extensitech

      It seems like this is probably a known issue, and if so, I apologize and just hope someone can point me to a solution. I couldn't find it.

       

      When showing a custom dialog, if the user hits enter, option 1 is selected (and expected; after all, the first button is highlighted).

       

      However, when the escape key is pressed, get ( lastmessagechoice ) also returns the default option (1), which is clearly not what the user intended. Get ( lasterror ) returns 0, so I have no indication that the user clearly either didn't want to pick one of the available options, or meant "cancel".

       

      I realize that I could change all default options to be "cancel", but that would mean that A) there would always have to be a cancel button (I almost always want one anyway, but still ) and B) the user would always have to mouse to the most likely option (they couldn't use the enter key).

       

      Has anyone come up with a way to differentiate between a user clicking escape and a user who selected option 1 by an intentional means?

       

      I'd prefer to discover that I'm missing an obscure get functoin or something, but if this requires something gimmicky, or even a plugin, it would be worth it to me.

       

      Chris Cain

      Extensitech, LLC

      ccain@extensitech.com

        • 1. Re: Capturing escape key for custom dialog
          TomHays

          Note that this is a Windows-only issue.

          The Esc key does not dismiss a custom dialog on Mac OS X.

           

          In FileMaker 13, one workaround is to restrict yourself to using 2 buttons instead of 3 and don't have a default button.  Leave the default button postion blank.  Get(LastMessageChoice) will be 1 when the Esc key is hit. It will be 2 or 3 for the other button choices.

           

          -Tom

          • 2. Re: Capturing escape key for custom dialog
            Extensitech

            This has the same issues as making the default button a cancel button every time.

             

            I did forget to mention that this is a Windows-only issue, which I had known. However, that's the majority of computer users in general, and my clients specifically.

            • 3. Re: Capturing escape key for custom dialog
              Mike Duncan

              This sounds like a possible candidate for using popup buttons to show a dialog instead. It's a little bit more work, but a lot more flexible once in place. In a popup, the escape key will close the popup, by default, so you can trap for that if you want until the user clicks on one of the intended buttons.

               

              Would that work?

              • 4. Re: Capturing escape key for custom dialog
                keywords

                Re: "The Esc key does not dismiss a custom dialog on Mac OS X."

                 

                That is not quite correct. It may behave differently on Windows, but on my Mac (OSX 10.9.5, FM13) if you hold the Esc key while pressing ANY button in a custom dialog window the dialog window is dismissed and the script is halted.

                • 5. Re: Capturing escape key for custom dialog
                  TomHays

                  I believe what you are observing is that the Esc key is serving to halt the script when the script resumes after the dialog is dismissed by a button press.  The Esc key is ignored while the modal dialog is active.  Once the script resumes the Esc key is registered to halt the script before the subsequent script steps can run.

                   

                  I expect (on Mac OS X) that you would observe the same behavior if you depressed Command and period instead of Esc.

                   

                  -Tom

                  • 6. Re: Capturing escape key for custom dialog
                    keywords

                    "Esc key is serving to halt the script when the script resumes"—spot on. By itself the Esc key does nothing.

                     

                    "you would observe the same behavior if you depressed Command and period"—confirmed.