6 Replies Latest reply on Jan 2, 2013 10:08 AM by samjs

    Script Trigger Keystroke


      With Filemaker 12, I'm try to setup a portal so that when I enter data in a field and press the "Return" key, it will trigger a script that will take me to the next portal row to enter new data in the same field.


      I've created a script...




      and have assigned the script trigger using "OnObjectKeystroke", but it will not work. What am I doing wrong?


      Thanks for your help!

        • 1. Re: Script Trigger Keystroke

          You probably don't need a script for that.  Go into layout mode and select the field.  Open the inspector,  open the data tab then the behavior section.   Then check retrun and enter for go to next object.   Under the layout menu select tab order and set up the the order in which you want  to move to objects.  Make sure you clear out itme you don't want the user to go to.




          • 2. Re: Script Trigger Keystroke

            I actually want the capability to tab through other fields also in the portal, but if I just want to enter data in the first field only, I want to use the "return" key to take me to the last portal row.

            • 3. Re: Script Trigger Keystroke

              In that case you can use an OnObjectkeystroke combined with get(triggerkeystroke).  Develop a script that interprets the characters using the Code function.


              So you script should look something like this:


              Set Variable [$c; code(getTriggerKeystroke]

              if [$c = 10 or $c = 13  // 10 = Enter  13 = Return

              perform Script [ move to last portal row]  // Your script probaby should committ the record and the go to the Portal Object and then last portal row.


              set field [ table::field;  table::field & $c]



              I haven't tested this on a field value but have used something very similar with OnLayoutKeystroke using a global field and scripted seaches.


              If you are still having trouble post your script or a small version of your DB so others can take a look.



              • 4. Re: Script Trigger Keystroke



                Thanks for your solution.  I've created a test file and for some reason, when I hit the return key, the script does not end. after 5 seconds, you can see the cancel icon appear where your mouse curser is, indicating that the script is still running.  I've attached the file to the original post.  Any help is greatly appreciated!

                • 5. Re: Script Trigger Keystroke

                  FileMaker Pro Advanced.png

                  This will do it.  Since you do not want the return added to the field, you need to tell the event to not execute the keystroke, that's where the Exit Script (false) comes in


                  Note however that this will always to to the very last row in your portal, not sure that is whay you intended to do.  You can avoid tthe commit and just do Go To Next Portal Row

                  • 6. Re: Script Trigger Keystroke

                    That is exactly what I want it to do!  Thanks so much!