11 Replies Latest reply on Mar 20, 2017 8:06 AM by rogerb52

    Get Active Tab Name -- How?

    MorkAfur

      Title

      Get Active Tab Name -- How?

      Post

      There doesn't seem to be a GET function like Get(ActiveTabName), so what's the trick to know what tab you're on (in a script, of course)?

      The only documentation I can find from FileMaker seems to assume I want to change tab to a named tab object. I can do that, but that's not what I want to do.

      My issue is that I have a toolbar whose buttons don't apply to each tab. Trying to put just "some" buttons on the various tabs would lead to a inconsistent design.

      The only other thing I found was to use the script step for when you change the tab. So, do I really need to do something like create a global variable ($$) and update it in a script each time I change tabs? That seems to be the only way to know the active tab name.

      Hopefully, I've overlooked a simpler method.

      Look forward to any suggestions.

      Thanks,

      -m

        • 1. Re: Get Active Tab Name -- How?
          philmodjunk

          If you are using FileMaker 12 or newer, the OnPanelSwitch trigger (name is different in v12) can perform a script. In that script, Get ( TriggerTargetPanel ) returns both the object name and the index (return separated list) of the newly front most target panel.

          Please note that the front panel of a tab control may not actually be "active" as an "active" layout object has the current focus via pressing a key on the keyboard (such as tab) to change that focus. (Mouse clicks may or may not change the focus depending on the object clicked. A clicked button, for example, does not become the active layout object.)

          • 2. Re: Get Active Tab Name -- How?
            DavidJondreau

            You can test whether predefined tabs are the frontmost or not using GetLayoutObjectAttribute ( tabName ; "isFrontPanel" ).

             

             

            1 of 1 people found this helpful
            • 3. Re: Get Active Tab Name -- How?
              MorkAfur

              Phil,

              The Get(TriggerTargetPanel)'s help says: "Use with the Get(TriggerCurrentPanel) function. Returns an index value, starting from 1, when running a script triggered by the OnPanelSwitch script trigger..."

              My situation is that I have a button on top of the tab display that I only want to have, in this case, create a new record, for certain tabs.

              Putting the GET(TriggerTargetPanel) in the "ADD RECORD" script always returns 0.

              Some object orientation would be super helpful here. Using the tab object name, there should be a function that returns data about that tab (tabObjectName.getActiveTabName(), ....).

              ----

              What am I missing?

              - m

              P.S. I also tried the GetLayoutObjectAttribute ( tabName ; "isFrontPanel" ) as David above suggested, but that also returns 0 on each tab.

              • 4. Re: Get Active Tab Name -- How?
                philmodjunk

                I recommended get ( TriggerTARGETpanel ) not the current panel version. Both of these get functions return both the index and the object name of the panel (if you use the inspector) to give the object names to your panels and both require using the OnPanelSwitch trigger to perform a script first.

                David's method seems much more straight forward, but object names have to be specifically assigned via the Name box in the inspector. These are not the labels you might assign via tab control set up.

                • 5. Re: Get Active Tab Name -- How?
                  MorkAfur

                  My button is not part of the tab control so it always displays zero.

                  I'll try to use the OnPanelSwitch trigger to set a global variable that I can check fro the button outside the tab control.

                  Seems like that's my best bet.

                  Appreciate the help.

                  - m

                  • 6. Re: Get Active Tab Name -- How?
                    philmodjunk

                    Actually, I think David had the better idea...

                    • 7. Re: Get Active Tab Name -- How?
                      MorkAfur

                      Perhaps I am confused in some way, but, from a button being used OUTSIDE the tab control, neither approach described above worked. They both always produced a zero (in get ( TriggerTARGETpanel )) regardless of the tab.

                      I have a toolbar outside the tab control where some buttons should work only on some tabs. In FMP, unfortunately, there is still no way that I know of to do the utterly basic thing, available in every other development environment I know of, of "graying out and disabling" a button using a logical condition. Perhaps in FMP 17? ;)

                      What I did get working was in the tab change event, I updated a global variable with the get ( TriggerTARGETpanel. Then, in the command button, which, again, is outside the tab control, I can see the correct tab panel chosen. I had to initialize the global variable to the default tab up front. This was much more of a cludge than should have been necessary.

                      With a more object oriented design (tabObject.method(), for example), this type of problem would be simple to work with. No global variables, etc.. And, I would argue would be even simpler.

                      However, FMP continues to amaze me with just how fast I can put something together that's usable. :)

                      Thanks,

                      • 8. Re: Get Active Tab Name -- How?
                        DavidJondreau

                        You don't need global variables or triggers. You just need to understand the tools FileMaker has.

                        Read the help file on GetLayoutObjectAttribute(). You'll need that to identify the frontmost tab panel.

                        While there isn't a super simple way to grey and disable a button, you can hide button using the "Hide object when..." option. You can also grey a button using conditional formatting and disable it by putting an Exit() condition early in the script.

                         

                        • 9. Re: Get Active Tab Name -- How?
                          MorkAfur

                          I think I took your example above literally ("isfrontTab").

                          This is still more difficult that it should be since even a non-object oriented "GET(ActiveTabName)" would be simple, easy to understand, and use.

                          Thanks again. :)

                          • 10. Re: Get Active Tab Name -- How?
                            Nick Austen

                            I'm sure you found a good way to do this, but for the benefit of any others, I had a similar challenge of wanting to be able to return to the Tab I was on at the completion of a script.

                            I did it by setting a global variable like this:

                             

                            Set Variable [$$ReturnToObject ; Value: GetValue (Get(TriggerTargetPanel);2)

                             

                            Value 2 gives me the name of the panel (you have to name them first of course), then at the end of the script its a simple

                            Go to Object $$ReturnToObject

                             

                            Hope it helps someone

                            • 11. Re: Get Active Tab Name -- How?
                              rogerb52

                              Thanks Nick, your solution was exactly what I needed!