6 Replies Latest reply on Jun 25, 2014 7:19 PM by indyj

    show/hide button with hide object when?

    indyj

      Title

      show/hide button with hide object when?

      Post

           Hi all,

           Is there any way to toggle the visibility of layout objects with a button? I would like to have some fields on a layout hidden by default, become visible when a button is pushed, and become hidden again when the button is pushed again. Is this possible? 

            

           Thanks!

        • 1. Re: show/hide button with hide object when?
          eoin

               Hi, you can use 2 buttons "Show" and "Hide" on your layout that each set the value of a global variable to a value , say "1" for the show and "0" to hide the items.

               Set a variable ($$Variable) to 0 with the on layout enter script step (your default hidden)

               The show buttons own visibility is set to hide when $$Variable = 1

               The hide buttons own viability is set to hide when $$Variable = 0

               Place the buttons directly over each other.

               Any fields or items you wish to hide, set their visibility to hide when $$Variable = 0

               you may or may not need a refresh window script step on the button, I can't recall.

          • 2. Re: show/hide button with hide object when?
            indyj

                 Thanks for the help Eoin,

                 I tried it, but I can't seem to get it to work. The hide buttons and fields with $$variable set to 0 works for the OnLayoutEnter trigger (when I enter the layout, the "Show" button is visible), but I can't toggle the $$variable value with the buttons. The "Hide" button stays hidden. What am I doing wrong? This is what I did:

                 I set a script trigger to run script OnLayoutEnter. The script is:

                 Set Variable [$$showhide ; value:0]

                 I then went to Button setup and set it to Set Variable [$$showhide ; value:1] for the show button, and Set Variable [$$showhide ; value:0] for the hide button. When that didn't work, I tried to set the buttons to run a script that set the variables instead, but that did not work either. 

                 I set the hide object when calculation to $$showhide = 1 for the show button, and $$showhide = 0 for the hide button.

                 I'm pretty new to FileMaker, sorry to be a pain!

                 Thanks

            • 3. Re: show/hide button with hide object when?
              indyj

                   I still don't know what I did wrong, but I worked around it: if I use a global field instead of a variable it works as expected. Thanks!

              • 4. Re: show/hide button with hide object when?
                eoin

                     It was the lack of a refresh window script step. I wasn't quite sure at the time I wrote the reply but checking now ... you need to refresh the window. you can check it by adding the script step in the script for each button or just use the menu RECORDS, REFRESH WINDOW to do a quick check. (shift+cmd+R on a Mac)

                     Like you, I'm new to filemaker, sorry about that.

                      

                • 5. Re: show/hide button with hide object when?
                  philmodjunk

                       Instead of Refresh Window, you might use Refresh Object as this allows you to update the appearance of a single object on your layout instead of the entire layout. You'll need to give your objects that appear/disappear an object name via the inspector's name box to pull that off, but it can result in less "layout flash" than refreshing the entire window.

                  • 6. Re: show/hide button with hide object when?
                    indyj

                         Thank you, I got it working - appreciate the help!