How do you create a toggle button?

Jul 06, 2022

I need to create a toggle button which opens a layer in a corner of the screen. I then want to use the same button to close the layer. How would I make a toggle button? I don't seem to be able to find any other thread on this topic.

11 Replies
Judy Nollet

How much stuff is on the layer? The easiest way to get that toggling may be to move the content from the layer into the Selected state of the button. A button with a Selected state will automatically toggle between Normal and Selected when it's clicked, so you wouldn't need any triggers (or layers). 

Judy Nollet

Glad to see that Michael jumped in with the toggle-variable solution. With that option, be sure to use a unique variable for each slide. Otherwise, the True/False values could get mixed up. 

Other options: 

  • Put a copy of the button on the layer, and give it a trigger to hide the layer. (If it's in the same position, the user won't know it's a different button.) 

or

  • Cover the base button. Use a separate button on the layer that specifically indicates it's for closing that content.  
Caryn Wagner

Judy,

I followed your suggestion of moving the content to the Selected state and it worked great, thank you! 

I then tried to put my 3 buttons in a button set, but now they are no longer toggling back to the Normal state when the same button is clicked. Is there a way to get around that?

Judy Nollet
I then tried to put my 3 buttons in a button set, but now they are no longer toggling back to the Normal state when the same button is clicked. Is there a way to get around that?

The point of a button set is to require the user to make a selection—and only 1 selection. For example, to indicate an answer to a question or to choose an avatar.

However, that means that to deselect a button in the set, the user has to select another button in the set. Or some other trigger has to change the button back to Normal.

Depending on your situation, you could try one of the following:

  • Remove the button set. (That works if no answer is required or if more than one item can be selected.)
  • Add a button to the set that's labeled something like "Clear selection." (Sure, technically, they'd be selecting that button. But that would deselect the other buttons with actual choices.)
Judy Nollet

If you can't get it to work, I suggest you start a new discussion to post the file. That's more likely to be seen than yet another entry on an older post.  (The Forum doesn't actually tag people. And one only gets notifications if they subscribe to a given post.) Having the particular issue in a separate post would probably be more helpful for those searching the Forum in the future.