5 Replies Latest reply on Sep 14, 2016 9:07 AM by ekamuf

    "Next/Previous" buttons on a tab control or slide control

    realgrouchy

      I was looking at some old discussions and Help topics ( Creating a Next button that goes to the next tab , Sliders with optional navigation arrows  , Determine Active Tab ) and realized there needs to be a better way to create "Next/Prevous" tabs than manually programming each individual Next and Previous button on each tab, as described in  How to navigate between tabs in a tab panel using scripts | FileMaker .

       

      I've created a script that allows you to go to the next/previous tab (including wraparound) using the same Next/Previous buttons on each tab.

       

      It requires naming each tab or slide with consistent and consecutive numbering, which also means that if you rearrange, add, or remove tabs, then you have to renumber the tabs in the tab control.

       

      This also works for slide controls.

       

      I'd be thrilled to know if there's a better way. If it were possible to get the object name of the currently selected Tab, it would be easier to extend this beyond 9 tabs/slide controls. I initially played with the idea of getting the next/previous button to simply go to Tab1 and using a script trigger to be able to determine the Get (TriggerCurrentPanel), but I couldn't find the right combination of settings (if one exists) to get it to work.

       

      - RG>

        • 1. Re: "Next/Previous" buttons on a tab control or slide control
          erolst

          My idea for a dynamic solution would have been to

           

          • get the <object name> of the slide/panel

          • get the name of the <enclosing object>

          • get a list of all object names on the layout

          • parse out the list of names contained within <enclosing object>

          • determine the position of <object name> in that list

          • go to the object whose name precedes or follows <object name>

           

          which failed me because I found no way to name the entire tab oder slide control – i.e. <enclosing object> – as opposed to individual tabs or slides.

           

          Just the other say I read a Wikipedia article about HyperCard/HyperTalk, which I never used in the day. FM could take some pages (or would that be cards) from the things that platform was capable of doing dynamically at runtime …

          • 2. Re: "Next/Previous" buttons on a tab control or slide control
            realgrouchy

            erolst But how do you get the object name of a slide/panel when you are clicking a button that is contained within it?

             

            I tried this but couldn't find a way.

             

            You could do GetLayoutObjectAttribute ( [buttonname] ; "enclosingObject" ), however you'd have to define the button name.

             

            Get ( ActiveLayoutObjectName ) doesn't seem to work get the the name of the button that was pressed, so you'd have to define the button name in each instance. You couldn't just use "PrevButton" and "NextButton" because once you copy the buttons, the copies become "PrevButton copy" and "NextButton copy" so you'd have to update the script in each of those instances. With the method I've used, you can copy and paste the button bar without having to change it, but the drawback is that you have to make sure the panels/slides are named properly.

             

            If there's something I'm missing, I'm all ears...

             

            Meanwhile, I'm voting up this idea: Sliders with optional navigation arrows

             

            (BTW: I should mention, for those who need to worry about copyright and all that, that I attached the file in the previous message with the intent of sharing it for others to use, so please go ahead and use it if you find it useful!)

             

            - RG>

            • 3. Re: "Next/Previous" buttons on a tab control or slide control
              erolst

              I think your objections are all valid, but I didn't even get far enough to notice them as such …

               

              One thing I could think of is to test a list of object names against "isFrontPanel". So the order wouldn't matter if you can get the position dynamically, but you'd still have to maintain the list proper.

              • 5. Re: "Next/Previous" buttons on a tab control or slide control
                ekamuf

                Here is the method I used, scaleable to as many tab panels as necessary.  You still have to name the panels  and they cannot be rearranged.

                 

                I named all of my panels Panel1 Panel2 Panel3 etc.

                 

                Then I have a next button with a parameter of next and a back button with a parameter of back.

                 

                Screen Shot 2016-09-14 at 11.02.12 AM.png