Is there any simple way to toggle between 2 states of a dynamic panel?

Assuming that I have a DP with 4 states: state1, state2, state3, and state4

Is there any simple way to toggle only between state2 and state3 on the click of a button?
I cannot delete state1 and state4 as these states are needed for another flow. Is this possible without any tedious logic or using variables etc?

Thanks!

There’s no way that I know of to do it without any logic.

The way I would do it is have one button that, when clicked, it checks to see if the panel is in the desired state. If it’s not, then it sets the panel to that state.

The only other way would be to use two buttons and “fake it”. Either put them in a dynamic panel that flips back-and-forth or put one on top of the other and show/hide the top button.

Specific_States.rp (80.8 KB)

Thank you huban! I really appreciate your help for creating the sample .rp file.

The only reason why I did not want to use logic is because my button’s click interaction already has several other actions like (Set Panel State, Set Selected/Checked, Set Variable Value, Set Text, Show/Hide, etc) set on it now. Adding a logic would mean I need to duplicate these actions within all the cases, as I don’t see a way to add the logic+cases just for one of the actions.

Is that even possible in Axure to set the logic on an action alone (Set Panel State) and not on the main interaction (Click or Tap) level?

Thanks again!

Yes. Anything listed under the “Interactions” tab supports logic cases. It’s a little hard to find, but it’s also possible to toggle cases between IF and ELSE IF:
image

It allows you to separate evaluating conditions that have nothing to do with one another. For example:

Let’s say that, no matter what, a global variable should be set when a button is clicked:
image
Now let’s say that if the state of a dynamic panel determines which of two shapes should be shown. Since the variable should always be set, it doesn’t need to be part of the condition to determine what shape to display, so you would toggle the first case of evaluating the panel state to IF:
image

Another thing to keep in mind is the interaction “Fire Event” is your friend. :smiling_face_with_three_hearts:
It allows you to put logic on a widget that other widgets can trigger kind of like a function. I often use them for what I call “page variables”. I have different actions set the text on a hidden widget and then trigger its “Move” event which performs something based on the value of it’s text.

Thank you huban!
I will try that :+1: