5 Replies Latest reply on Aug 27, 2013 3:40 PM by deathrobot

    Trouble with script triggers and tab switching

    deathrobot

      Title

      Trouble with script triggers and tab switching

      Post

           I am having a bit of trouble with a technique of switching tabs via script from Seedcode:

           http://www.seedcode.com/filemaker-12-layout-tricks-hiding-tabs/

           There are two parts to having this work. The first part is that you set the tabs to an OnTabSwitch script trigger that calls:

                If [ isEmpty (Get (ScriptParameter ) ) ]
                    Exit Script [ Result: False ]
               End If

           with a script parameter of "Get ( ScriptName )". This makes it so that the user cannot change tabs by clicking with a mouse (since there is no ScriptName). But, if a script uses Go to Object [ Object Name: the tab's object name ], the tab switch will work.

           What I'm trying to do is to switch between tabs when changing modes (e.g. from Browse to Find). I am using a layout script trigger using onModeEnter. The script called is this:

                If [ Get ( WindowMode ) = 1 ]
                     Go to Object [ Object Name: "Find Tab" ]
                     Exit Script []
                End If
                Go to Object [ Object Name: "Browse Tab" ]

           If I enter find mode, the script is triggered and the tab correctly switches to what I've labeled as "Find Tab". However, when I switch back to Browse mode, the "Find Tab" stays active; it does not switch back to what I've labeled as "Browse Tab". If I disable the OnTabSwitch script, changing modes works correctly. Can't see why this would be though, since the tab change is being called by a script, therby making the script parameter NOT empty. Am I missing something obvious?

           Thanks,
           Michael

        • 1. Re: Trouble with script triggers and tab switching
          SteveMartino

               If this works for your solution, why not hide the tab labels altogether, being you need one tab on browse and a different  tab for find, and don't want the user to be able to switch them?  Then you could use OnModeEnter or OnModeExit triggers to control the tabs.  Maybe you could use those with your existing scripts to get it to do what you need it to do.

          • 2. Re: Trouble with script triggers and tab switching
            deathrobot

                 Thanks Steve. I am actually already hiding the tabs using conditional formatting [ ( Formula: Get ( WindowMode ) ≠ 4 ) set font size to 500 ]. The purpose of the SeedCode script is to prevent the user from clicking on the tabs, but when you're in Layout mode, you can see the tab and tab names; makes it nicer to deal with when editing  the layout. And, the script is working for me with OnModeEnter, but only going from Browse Mode to Find Mode, not the other way around. I've checked my labels numerous times and they seem to be correct, so I can't figure out why it's not working when going from Find to Browse.

                 Michael

            • 3. Re: Trouble with script triggers and tab switching
              philmodjunk

                   I suggest the following changes:

                    If [Not $$ModeChange ]
                            Exit Script [ Result: False ]
                    End If

                   Set Variable [$$ModeChange ; Value: True ]
                   If [ Get ( WindowMode ) = 1 ]
                             Go to Object [ Object Name: "Find Tab" ]
                   Else
                             Go to Object [ Object Name: "Browse Tab" ]
                   End If
                   Set Variable [$$ModeChange ; Value : False ]
                     

              • 4. Re: Trouble with script triggers and tab switching
                DavidJondreau

                     Your script structure is a little wonky, but the simplest solution is to put an Exit Script[] at the end of your script.

                     Why?

                     Because on the Go to Object for Browse, the script is done and nothing gets passed to the Tab Switch Trigger script. With an Exit Script[], that script is still live after to Go to Object[].

                • 5. Re: Trouble with script triggers and tab switching
                  deathrobot

                       Thanks Phil and David. I first tried your solution, David, since it was easier, but it didn't work for me. Not sure why; it made complete sense. Then tried your solution, Phil. This did solve it. Thanks to you both.

                       Michael