5 Replies Latest reply on Jan 21, 2016 10:48 AM by googull

    How to do something like an OnWindowActivate script trigger?

    tcmeyers

      It would be very useful to me, and others I bet, if there were an OnWindowActivate script trigger, I presume it would belong in the Layout set of script triggers, or possibly less conveniently, in the File Options group of script triggers.

       

      This would fire when a window was made the active one, brought to the front or uncovered by closing the one on top. Since OnLayoutKeystroke does not work in the iOS environment, having this script trigger would help me cope with the situation.

       

      It would probably come in handy for anyone who has a window that might need to have its content refreshed if work in another window might have altered related calculations that are stubborn to reveal their new values.

       

      Is there a way of doing this that I'm missing, or a trick? OnLayoutLoad doesn't do it, that fires only when a layout is first switched-to. Nor does OnWindowOpen.

       

      Troy

        • 1. Re: How to do something like an OnWindowActivate script trigger?
          steve_ssh

          Hello Troy,


          In an FMP/A environment that allows for plugins, you can use a technique described at the following post:


            https://community.filemaker.com/message/91430


          Essentially the idea is this:


          1) Define a custom MenuSet that you apply to all windows that need this "On Activate" trigger feature.


          2) In the custom MenuSet, override one of the menus such that the Menu title is determined via calculation.


          3) In the calculation to return the Menu title, you can return the standard title for the menu, but somewhere in the body of the calculation, send a command (via plugin) to trigger an FMP script.  This script will act as your "On Window Activate" trigger.

           

           

          How It Works:

           

          When a different window is revealed/selected during the course of user action, the MenuBar will re-evaluate the function that returns the menu title.  This is the hook that triggers your calculation, which in turn, triggers your handler script.

           

           

          Notes:

           

          1) You should not need to create multiple MenuSets to make this happen.  The same modified MenuSet can be used across as many windows as you choose.

           

          2) There are at least a few free plugins that should offer you the ability to trigger a script from the calculation engine.  I believe that any one of them should work fine.  I have not tried this on a Windows system, but IIRC, the OP of the post mentioned above had success with this on both OS X and Windows.

           

          3) I can't recall whether or not I re-tested this function when v.14 was released.  It's possible that I did not.  I hope it still works!

           

           

          Very kind regards & HTH,

           

          -steve

          • 2. Re: How to do something like an OnWindowActivate script trigger?
            tcmeyers

            Steve,

             

            Thank you very much. Though in this case needed the trigger for an iOS situation, I may well apply it to desktop problems, clever!

             

            Perhaps the existence of this workaround means that I'm not just missing this as a native FileMaker ability?

             

            Troy

            • 3. Re: How to do something like an OnWindowActivate script trigger?
              steve_ssh

              Hi Troy,

               

              If there is a more direct/native means of doing this, then I'm missing it, too. 

               

              Sorry that it doesn't work for iOS.  If I come across some other clever workaround suitable for iOS, I'll post back...

               

              Very best,

               

              -steve

              • 4. Re: How to do something like an OnWindowActivate script trigger?
                tcmeyers

                Steve, and anyone else interested in getting this feature, I've added a New Feature Request.

                 

                Please do the same to chime in? Here is what I wrote:

                 

                (The link for Feature Request:)

                Company | FileMaker

                 

                Request Title:

                OnWindowActivate script trigger (and OnWindowDeactivate)

                 

                It would be very useful to be able to fire a script when a window becomes the active window, either by it being clicked on (or selected in the iOS Window chooser) or being uncovered by another being closed, or if being activated by script. This could be used, for example, to trigger object or entire window refreshes. Similarly, the corresponding Deactivate script could be used to Commit a record when the window is hidden, moved to the dock (minimized), or loses focus because a new window is active. I would use this to help prevent "can't modify because record open in other window" errors.

                • 5. Re: How to do something like an OnWindowActivate script trigger?
                  googull

                  Troy - I have used tons of time trying to resolve the lack of window coordination without triggers to detect window activation.  Really happy to see your posting. I was unable to find it though in the New Feature Request area.  I want to vote for it!

                   

                  Carl