11 Replies Latest reply on Feb 16, 2015 6:42 AM by DLarsen

    Exit Field Focus


      Hello all,


      I have a read only layout (list view) where I have a global field in the header section that I would like to use to search most of the fields on the layout. Basically I'm trying to replicate the Quick Find feature that's in the upper right corner of native Filemaker.


      I've scripted the action and it returns the records as expected but I can't get the cursor to leave that global field when the script concludes. I think the problem stems from the fact that it's the only enterable field on the layout.


      I've tried:

      GoTo Field [ ]

      Commit Records/Requests

      Go to Object [ ]


      Nothing seems to work.  Anybody been able to solve this one?



        • 1. Re: Exit Field Focus

          Try removing the field from the tab order.

          • 2. Re: Exit Field Focus

            I can't replicate this behaviour in your exact configuration.


            With the global search field being the only enterable field on the layout, it does not gain / regain focus after performing the script (even if it is in the tab order).

            • 3. Re: Exit Field Focus

              Put a Halt script script step after the commit.

              • 4. Re: Exit Field Focus

                I think this is normal behaviour, the focus has nowhere to go except that field.

                If the field won't let you leave when clicking outside, put ExitScript: Result = True at the end.

                I've the same situation but I prefer to trigger on object save. This fires only if the value has been modified.

                On exit will fire twice, once for Tab / Return and once if you click outside.


                EDIT: +1 to siplus. Halt doest the trick!

                • 5. Re: Exit Field Focus

                  Halt is very aggressive and I would avoid it to overcome this kind of problem.  Using Halt will kill the entire script stack so you can never run this script as a subscript of a longer set of scripts.


                  While it may solve it for this issue, I agree with erolst: there  Commit and Go To Field[] will remove focus from the field.  Always.  So there must be some other thing going on in your layout, perhaps a onLayoutLode, onModeEnter, onRecordLoad trigger that resets focus?

                  • 6. Re: Exit Field Focus

                    Maybe OS dependent? on my machine > Mac OSX it doesn't work.

                    Clicking outside of the field does, tabbing doesn't. No other triggers are defined for the layout.

                    No difference it it has a tab order defined or not.

                    Screen Shot 2015-02-15 at 14.46.27.png

                    OTOH, actually I find this a useful feature. No need to select the field again if I don't like the search result.

                    Just a preference.

                    • 7. Re: Exit Field Focus

                      We know that halt script kills everything and must be used carefully.


                      On the other side, I had this problem myself many times, times when commit and go to field and exit script and go to object and tab order  and and... won't solve the problem, while halt script will.


                      I rarely pretend or try to resolve all future issues in my replies. But I do try to resolve the current issue. Like grand prix tire change. Gotta happen fast. Even if after 2 rounds rain comes and it's not the right tire anymore. Because I think that people posting here do want an instant glue, 1-minute-hard_as_rock, more than a academic course about what's not kosher in FM. YMMW. And if they are posting here and get the instant glue and they have what it takes, they will hopefully take the right road next time; for now, I say what I would do, which is often similar but not equal to what has to be done....


                      TLDR When I place a Go to field [] in a script and Filemaker still goes to a field, then all weapons available are allowed.

                      • 8. Re: Exit Field Focus

                        when you use gotoObject it needs to have an object name.  Your example script dosen't have an object name.  Make sure the name of the object is copied from the layout and pasted into the script step.


                        I have done a lot of scripts like this and this usually does the trick



                        • 9. Re: Exit Field Focus

                          Hi Doug,


                          There are several alternative ways of accomplishing your objective.


                          Ray Cologon has an Instant Search demo which replicated Quick Find to make it field specific.

                          NightWing Enterprises - X4X - Instant Search Demo for FileMaker Pro


                          I've found it better to follow the approach that Tom Fitch demonstrated during one of Albert's Design Caucuses. He has a global field in the header for each of the fields he wants to search. The one script trigger attached to each of those global fields, runs after each keystroke. It captures the field name, performs a find on whatever has been typed into any of those fields, then returns to the cursor to to end of whatever was previously typed.

                          Below is an old screen shot that shows his script.


                          These may be overkill for what you need but I found it useful to explore each of the above methods.





                          Tom Fitch Find Triggers.png

                          • 10. Re: Exit Field Focus

                            I think the thing that is missing is the last line in the script.  If should be Exit Script[Result: False ]


                            So for example for a simple version of this you have a Global text field called SEARCH and want to use quick find.  Setting up a onObjectModify script for the Global Field your script could look like this.  Assume that the Object name for the field is "Search"


                            if (isempty(Table::SEARCH)

                              show all records


                            Perform Quick FInd[ Table::SEARCH]

                            End if

                            Go To Object[Object Name: "Search"]

                            Exit Script[Result: False ]


                            You can add anything you want in the else portion so that it will search one or more specific fields or you can add a loop and several records to limit or expand your search.



                            • 11. Re: Exit Field Focus

                              After spending some time on this I had some success using a couple different methods. In the end Bruce's suggestions come closest to what I used.


                              The tab order didn't seem to matter at all. Halt script worked and I wouldn't hesitate to use it if there were no other scripts running but the method I chose was:


                              Go To Object ["Logo"]

                              Exit Script [Result: False]


                              The layout has a company logo (PNG graphic object) so I named it "Logo" and going to it actually does nothing other than take the focus away from (global) search field. Exit Script with a TRUE or NULL result didn't seem to work but FALSE did so I'm in business.


                              Thanks for all the suggestions!