Forum Discussion
Help with seemingly simple button logic
Hi all,
I'm trying to figure out how to change a button state when you click on it, then change it back to the original state when you click it again. It seems simple, but it just won't work for me, and I'm hoping someone here will tell me where I'm going wrong. I've tried to include the file here, but it won't let me upload the file.
All I want is to when I click on the button (starts off in the "Off" state) to change to a new state (ie "On" state), but then when I click it again, it switched back to the original state (ie the "Off" state).
Currently, I can get it to change once to the "On" state, but it won't change back to the "Off" state when I click it again. I've added a tracking T/F variable called "buttonOn" as a way of controlling the state of the button. The button (called OnOff Button) has two states: Normal and buttonOn)
Here are the triggers I've got in the order they appear:
1) Set buttonOn to value True
When the state of OnOff Button is buttonIsOn
2) Set buttonOn to value False
When the state of OnOff Button is Normal
3) Set state of OnOff Button to Normal -----> (ie State 1)
When the user clicks OnOff Button
If buttonOn = value True
(ie change the button to be Off when the user clicks the button and visual state of the button is On)
4) Set state of OnOff Button to buttonIsOn ----> (ie State 2)
When the user clicks OnOff Button
If buttonOn = value False
(ie change the button to be On when the user clicks the button and the visual state of the button is Off)
Seems logical to me, but it doesn't work. I can get it to change once, but it won't change back to the original state. I can do it using layers, but I'd rather stick with changing states.
What am I doing wrong? I can send you the .story file for anyone who would like to see it.
i've noticed that when I try editing the different states, there are triggers that appear where I can't delete them. Is this normal?
- RonPricePartner
Hey Doug,
This behavior you have described "I'm trying to figure out how to change a button state when you click on it, then change it back to the original state when you click it again." is the exact behavior that a "Selected" State provides without adding any additional triggers.
https://access.articulate.com/support/article/Articulate-Storyline-360-Definition-of-Built-In-States
- JudyNolletSuper Hero
Posting the same question in multiple areas and/or multiple times might seem like a good way to get noticed.
For example, you posted this question in both the Building Better Courses and the Storyline area.
- https://community.articulate.com/discussions/building-better-courses/help-needed-with-seemingly-simple-logic
- https://community.articulate.com/discussions/articulate-storyline/help-with-seemingly-simple-button-logic
- https://community.articulate.com/discussions/articulate-storyline/help-with-seemingly-simple-button-logic-eb3fb514-4cea-439c-bc0d-469d519fbc38
I'm assuming that the 2 posts in the Storyline area are due to the issues you had with your posts being auto-reported.
Duplicating posts complicates getting a good answer, since different folks might reply to different posts (as with this post). That also makes it harder for someone else who's searching for the answer to the same or a similar question.