2 Replies Latest reply on Jul 10, 2015 9:38 AM by RyanDunn_1

    Change Active Field to Avoid Loop in OnObjectExit

    RyanDunn_1

      Title

      Change Active Field to Avoid Loop in OnObjectExit

      Post

      Hello,
      I have a multiple portal row layout with a multiple drop-down menus that will execute scripts with 'OnObjectExit' enabled. Once the script is finished executing, a generic field is then activated outside of the multiple portal row layout, but I do not see any code within the scripts that is performing the field activation. All the drop down menu's perform this task perfectly, except for one. Instead of activating the generic field, it moves down the next portal row, activates it, then the 'OnObjectExit' gets called again when I click elsewhere, and then I'm in a big loop of ugly.


      I've tried adding in 'Go To Field[] ' and 'Go To Object[] ' in this rogue script, and it would activate the desired location, but when the script ends, the next portal row will activate, and I'm back in the hideous loop of ugly. The proper functionality behaves the same way. Once the script has ended, then the generic field is activated, but instead of going to the next portal row, it stays on the generic field.


      Is there any behind the scenes operations that filemaker uses to go to a certain field/location after a script has been performed? That seems to be the issue, but I cannot find where any setting like this could be. I've attached an image of what is happening. Hopefully the picture will help in more detail.

      Thanks,

      Ryan

      loopIssue.png

        • 1. Re: Change Active Field to Avoid Loop in OnObjectExit
          philmodjunk

          OnObjectExit is a "before the event" script trigger. That means that when you trip this trigger, the script runs first and then FileMaker processes the event that tripped the trigger once the script has finished executing. So for OnObjectExit, if you press a key such as tab, return, or enter to exit the field, the script will run and then FileMaker will process the event by putting the cursor into the next field of your layout's specified tab order. That's why you can't find any code that puts the focus there and why, if you try to use go to field, or another such step you don't find the cursor where that step put it. FileMaker DOES put the cursor where specified, but then the script finishes and that event gets processed and the cursor is moved again to the next object in the tab order.

          But you can keep such triggering events from being processed with "before the event" triggers if you make this script step the last step in your script:

          Exit Script [False]

          To find out which triggers are "before the event" and which are "after the event", see "Setting up Script Triggers" in FileMaker Help where you'll find a handy chart listing all available triggers and identifying which category they belong to.

          • 2. Re: Change Active Field to Avoid Loop in OnObjectExit
            RyanDunn_1

            You sir, are Legend!

            Thanks for the fast response. I didn't know each layout had a tab order, and sure enough that was the issue.

            Thanks again!

            Ryan