4 Replies Latest reply on Apr 1, 2013 10:21 AM by philmodjunk

    Problems trapping Close Window [ X ]

    donjuancarlos_1

      Title

      Problems trapping Close Window [ X ]

      Post

           FileMaker 12 both versions,  Windows 7

           I run a script when a user closes a window to update some calculations.  It works fine.

            

           However it does not work in this scenario:

            

             
      1.           User has Windows A and B open in database file Quotes.fp12.
      2.      
      3.           Window B is Active.
      4.      
      5.           User clicks the Red X on Window A to run the Close script and then close Window A.
      6.      
      7.           FileMaker/Windows intercepts the Close event and performs it on the active window, Window B.

           Does anyone know of a workaround?

            

        • 1. Re: Problems trapping Close Window [ X ]
          Jade

               One workaround, using FMP Advanced, is to disable the Red X  Close button(s) in the New WIndow[] scripstep using "Specify Advanced Styles" and replace the standard File>Close menu with a custom menu that updates your calculations and also closes the window. The user must then raise Window A before closing it with the menu or a shortcut.

          • 2. Re: Problems trapping Close Window [ X ]
            philmodjunk

                 Exactly how did you set this up?

                 On FileMaker 12.03, Windows XP, I ran the following test:

                 I created a script:

                 Show Custom Dialog [ Get ( WIndowName ) ]

                 I set the OnWIndowClose script trigger in FileOptions to perform that script.

                 I then used New Window in the Window menu to create two windows, resizing and positioning windows so that I could see both close buttons in the upper right corner.

                 I clicked the close button for the window in back

                 The custom dialog popped up showing the name of the window being closed. This shows the focus is on the correct window and any script steps that I put in place of Show Custom Dialog should run from the context of the window that is about to be closed.

            • 3. Re: Problems trapping Close Window [ X ]
              donjuancarlos_1

                   That's because what I am doing is using a custom menu to trap the Close command, not using the OnWindowClose command (my script started in FileMaker 10).  The trapped Close is what closes the wrong window

                   Now that I have played with OnWindowClose a bit, I see that this a vastly superior solution and a wlecome addition, so I will rewrite my script. Thanks!

              • 4. Re: Problems trapping Close Window [ X ]
                philmodjunk

                     I use the custom menu option a lot and haven't had this problem, but then I don't normally set up a situation where you would be closing the underlying file, I almost always use a second window as a modal input dialog that prevents the user from interacting with the underlying window until the first window is closed.