4 Replies Latest reply on Nov 16, 2009 2:59 PM by DLW-BPEX

    Assign script to tab panel



      Assign script to tab panel


      In FMP10 Advanced, is it possible to assign a particular script to a single tab panel?

      Situation: Tab A, Tab B, Tab C all on a layout. With Tab A showing, I would like to have a particular script launch when I click Tab B. A different script with Tab C. Yet a different when going back to Tab A.


      I can overlay a tab with a button to launch the script, but that is effective only AFTER the selected tab's panel is visible. I need it to run the script upon being selected.


      I'm sure this can be simulated with fake tabs and buttons, separate layouts, and OnLayoutLoad script triggers for each. But is there a way to do it directly?


      Thank you.


        • 1. Re: Assign script to tab panel
             You will need a script trigger, onObjectModify. You will still have to check which tab it is by using Get(LayoutObjectAttribute) and checking if the object is the front panel.
          • 2. Re: Assign script to tab panel

            Perfect! I was restricting my thinking to the script triggers associated with Layout Setup (Doh!). The help notes for OnObjectModify even say, "This script trigger activates if used in a tab control when the tabs are switched."


            Thank you, mr_vodka. You have been a tremendous help.


            • 3. Re: Assign script to tab panel

              So, for example,


              1) give a name to each tab ( something like 0, 1, 2 for a 3 tabs control)

              2) create a script like this:


              Set variable [ $activeTab; Value:Let(
                                                                  x = Case(
                                                                                 GetLayoutObjectAttribute ( 0 ; "IsFrontTabPanel" ) ; 0 ;
                                                                                 GetLayoutObjectAttribute ( 1 ; "IsFrontTabPanel" ) ; 1 ;
                                                                                 GetLayoutObjectAttribute ( 2 ; "IsFrontTabPanel" ) ; 2
                                                                                  ) ;
                                                                   Choose ( x ; "tab1" ; "tab2" ; "tab3" )
                                                                   ) ]
              Show Custom Dialog [ $activeTab ]

              • 4. Re: Assign script to tab panel

                Thank you. I had started something similar, but using If and Else If. Case and Choose probably is a cleaner approach.