6 Replies Latest reply on May 16, 2014 5:23 AM by IanJempson

    OnObjectExit Forking Depending on HOW the Object Is Exited

    richardsrussell

      There are 3 main ways to exit a field:

      tab out of it

      • press enter (or click outside an enterable area) to commit the record as a whole

      • click in some other field

       

      If I'm just sailing along, entering data, and I want to tab out of a field into another one, ObObjectExit works just fine. I've got it set up to interrogate the contents of the field to determine where to go next.

       

      But what if I don't want to tab out of it but instead click elsewhere? Or press enter to exit the entire record? The triggered script fires anyway, and I don't get the results I want. How can I get this tirggered script to fire only when the exit method is a tab keystroke?

       

      FMPA 12 on a Mac.

        • 1. Re: OnObjectExit Forking Depending on HOW the Object Is Exited
          erolst

          Probably (not tested for side effects in the wild) by using an OnObjectKeystroke trigger (Instead of OnObjectExit) and a test If [ Get ( TriggerKeystroke ) = Char (9) ], basically writing your own OnObjectExit method.

           

          Or have OnObjectKeystroke set a flag, then exit the field, so your OnObjectExit kicks in, checks for the flag and branches correspondingly.

          • 2. Re: OnObjectExit Forking Depending on HOW the Object Is Exited
            richardsrussell

            OK, I'm sufficiently frustrated by this that I'm replying to myself. I'm using the script shown below, and AFAICT, I'm doing everything I'm supposed to do to test for incoming keystrokes, but when I use Script Debugger while trying to activate the script, I find that:

            • the topmost "if" statement isn't activated when I press enter.

            • the middle one is bypassed when I press shift-tab.

            • the bottom one is ignored when I just press an ordinary tab.

             

            Triggered Script.png

             

            Thus, control never even gets to the "Commit Records" or "Go to Field" steps. In fact, if I run the script the way you see it here, the cursor just stays flashing in the "Addr Street" field and can't be extracted at all, by any method, without deactivating every step in the script.

             

            As we used to say in the Old Country, WTF!?

            • 3. Re: OnObjectExit Forking Depending on HOW the Object Is Exited
              erolst

              1. Is the script triggered by OnObjectExit? Get ( TriggerKeytroke) only gives a result when used with the OnKeystroke triggers. Thus my suggestion to listen for selected keystrokes, then pass control to OnObjectExit if you detect one

               

              2. True and False are keywords, not string expressions, so they don't work if put them in quotes – or more precisely, both will evaluate to false.

              • 4. Re: OnObjectExit Forking Depending on HOW the Object Is Exited
                AlanStirling

                Hi Richard

                 

                Just a thought about a different approach to your problem.

                 

                When your user tabs from one field to another, the target field remains active and can be checked by Get(ActiveFieldName). If the user has typed 'Enter', or clicked outside any fields, this function will provide an empty result.  So by testing for an entry in this field, you can confirm that the 'Tab' key has been used.

                 

                However, you will also need to check if the user has clicked in a different field, one not the next in the tab order.  So a script trigger OnObjectEnter can be used to see if the current active field is the one that follows the previous field in the tab order.

                 

                Then, in the same script, use a Global Variable to set the name of the next field in the tab order, using a calc that has a case statement for each field name, loading the next field name, when the current name matches.  If the result of Get(ActiveFieldName) does not match the contents of the Global Variable, then the user has clicked in a different field.

                 

                I hope this gives you some ideas on a different approach.

                 

                Best wishes - Alan Stirling, London UK.

                • 5. Re: OnObjectExit Forking Depending on HOW the Object Is Exited
                  markcox

                  Sorry. But it's pretty basic to want a script to run when you press enter, return or tab.

                   

                  We do it every time we google. And for this to be such a convoluted thing to accomplish, is pretty stupid if you ask me.

                   

                  It just makes me want to drop the software in the trash.

                  • 6. Re: OnObjectExit Forking Depending on HOW the Object Is Exited
                    IanJempson

                    It's not convoluted at all. The OnKeystroke trigger provides that capabiity out of the box.