10 Replies Latest reply on Dec 21, 2012 7:30 AM by DavidJondreau

    A way to enable/disable individual tabs

    Claw'd

      Hi all

       

      This demo file showcases a way to enable/disable any tab or tabs on a tab object.

       

      It uses FileMakers new tab script trigger which fires before the tab is activated and on modification which triggers after the event. these two triggers enable finding which tab was active and which tab is now active, this works quite well over a WAN connection on iOS as well.

       

      Any how as with most things filemaker there are lots of way to do things so putting it up here may help to improve the basic demo.

       

      This functionality helps to do away with having to have buttons replacing tabs or having to make multiple layouts for different view criteria.

       

      A nice touch is that with an enabled tab the mouse over colour changes to indicate activity while if the disabled tab colour is set to the same as the hover colour the tab just sits there not doing anything with it's text greyed out too.

        • 1. Re: A way to enable/disable individual tabs
          beverly

          NICE example!

          Beverly

          • 2. Re: A way to enable/disable individual tabs
            Claw'd

            Thanks Beverly, quite a lot of hair on the floor to get there though:)

            • 3. Re: A way to enable/disable individual tabs
              Claw'd

              Hi Bruce

               

              Thanks for the positive comment:)

               

              I think the applied theme makes it that way, tried a few others and got a different colour each time, so themes gives a different colour to each state: Normal, hover, selected etc.

               

              Just going to try to override the theme setting

              • 4. Re: A way to enable/disable individual tabs
                DavidJondreau

                No offense, but this seems way overly complicated. You can store the list of prohibited tabs in a global variable and the OnTabSwitch trigger can Exit[False] if the Get ( TriggerTargetTabPanel ) is in the variable. If you want to store a list of prohibited tabs, you could use a field in the table to store prohibited tabs. But you've got like 7 scripts and 6 fields.

                 

                Also, you don't need the OnModify, FileMaker has functions to grab the tab numbers of the start and end tabs.

                 

                Attached is an example...

                 

                The examples both need an onRecordLoad trigger to avoid a prohibited tab if it's default. And the Toggle script needs to account for when you toggle off permission of the tab you're on. There's a couple ways to handle that.

                • 5. Re: A way to enable/disable individual tabs
                  Claw'd

                  As I said in the first post there are many ways to do this but yours does streamline the whole thing so thanks for posting it.

                   

                  How in your version would you handle when on a tab that becomes disabled as it just seems to stay there which would be no good if that tab was supposed to be not avalable.

                   

                  All this is iterative and making things more elegant is a process, so I appreciate your comments.

                  • 6. Re: A way to enable/disable individual tabs
                    DavidJondreau

                    There's a few ways, but it seems odd that someone would be able to toggle a tab on and off they currently have access to and then it's supposed to hide. Part of the answer depends on what tab should become active if the current tab is toggled off? And what should happen if ALL the tabs are toggled off?

                     

                    Personally, I'd say you want one extra tab that has 'universal access' that won't be toggled off and could just be blank. If the toggled tab is active, go to that tab.

                     

                    Note your sample doesn't do this either if the selected tab is tab A and it's toggled off.

                    • 7. Re: A way to enable/disable individual tabs
                      Claw'd

                      Just checking but a few of the scripts are there because they where trying different approaches and only two scripts are used on the tabs, the button scripts could easily become a case statement in a single script and the fields could be replaced by variables. but hey, yours is simpler.

                      • 8. Re: A way to enable/disable individual tabs
                        Claw'd

                        Yes, had noticed that, if the tabs became disabled as part of a wizard or when a condition was met I guess the active tab could be disabled, bit of an edge case though.

                        • 9. Re: A way to enable/disable individual tabs
                          Claw'd

                          Stopping to think about where this idea came from reveals that the four scripts for the buttons are there just to set and unset the fields to show what would happen if the field where empty or full, the buttons and the button scripts are not needed other than for this purpose, the fields themselves are representations of fields from tables that would be on each tab layout or at least referenced by a relationship and would normally be filled or left blank during the course of entering data in other parts of the solution: So we come down to two fields: one to hold the current tab No. and the other to hold the last tab (this could be a variable) and two scripts, one to set the variable for which tab was pressed and the other to see what state the fields are in i.e. empty or filled. So not really 'way overly complicated' or '7 scripts and 6 fields'. Granted Davids way of testing if a tab is enabled or disabled is better in execution as it only runs once.

                           

                          What I have learned from this is that I need to be more thorough in describing the processes in the example file to minimise any misunderstanding.

                           

                          The webviewer is not required for this to work and the scripts other than GoToTab1, CheckFields and SetVariable are not needed so I should have removed these before posting.

                          • 10. Re: A way to enable/disable individual tabs
                            DavidJondreau

                            As a general rule, if you can avoid using fields in data tables for interface elements, you should.