7 Replies Latest reply on Mar 3, 2014 1:47 PM by peteraddison

    Test if Window is open.

    RonCates

      Title

      Test if Window is open.

      Post

      On firing a script that opens a new window how would I check to see if the window is already open (perhaps lost behind the main window) and if it is go to it and bring it forward?

        • 1. Re: Test if Window is open.
          philmodjunk

          WindowNames will return a list of the names of all currently open windows. If you want to see if a window named "High Score" is already open, this test will work:

          If [ Not IsEmpty ( FilterValues ( WindowNames ; "High Score" ) ) /* Window is already open */]

          There are also scripting tricks that can prevent a user from losing a window back behind other windows that can be implemented by simulating "modal" window behavior. (User is prevented from interacting with other FileMaker windows until they close the current "modal" window.)

          2 of 2 people found this helpful
          • 2. Re: Test if Window is open.
            RonCates

            Thanks Phil. You are a great help as always :)

             

            • 3. Re: Test if Window is open.
              RonCates

              I'm doing a find layout in a new window. How would I set the global to fire the find script when the user hits enter.

              • 4. Re: Test if Window is open.
                philmodjunk

                OnObjectKeystroke can be used to fire a script. The script can use Get ( TriggerKeystroke ) to check to see if the key pressed was the enter key. (Char ( 10 ) is the enter key )

                • 5. Re: Test if Window is open.
                  RonCates

                  Perfect. Thanks once again Phil :)

                  • 6. Re: Test if Window is open.
                    DobrilAtanasov

                         Hi there,

                         this is my first post, but I got an elegant solution to this matter. Check out the attached picture for my real time script, works great!

                         I basically try to select the window, if it is not open it reports an error, which triggers opening a new window using an if script step! 

                    • 7. Re: Test if Window is open.
                      peteraddison

                           If you call a window and it's not there, it returns error 112 

                           After the "select window", test the for that error. 

                           If Get(LastError) = 112

                           then you know it's not there and you can create a new one.

                            

                           eg:

                           Select Window [Name: "MyWindow"; Current File]
                           If [Get (LastError) = 112
                                Set Window Title [Current Window; New Title: "MyWindow"]
                           End If

                           This selects the window, if it exists. If not, it changes the title of the Current Window to be the one you want and uses that window. (That way you don't have to close it. -- Reduce, Reuse, Recycle!)

                      1 of 1 people found this helpful