Forum Discussion
Changing States when a learner clicks the object
I have inserted a picture of a media play button. To that picture, I added a state called “pause” in which the picture is replaced with an image of a pause button. The initial state is set to normal.
The idea is to create a single button that the learner can use to pause and resume a video. This is being done for client-required accessibility requirements, to make the player controls more visible. I will also be adding similar buttons for stop/exit, jump forward 10 seconds, and jump back 10 seconds.
If I add a single trigger that says “change state of picture1 to pause when user clicks picture1,” it works.
If I add a trigger that says “change state of picture1 to pause when user clicks picture1 IF state of picture1 is normal,” it works.
If I set the initial state to pause and add a trigger that says “change state of picture1 to normal when user clicks picture1 IF state of picture1 is pause,” it works.
However, if I add two triggers:
“change state of picture1 to pause when user clicks picture1 if state of picture1 is normal,”
AND
“change state of picture1 to normal when user clicks picture1 if state of picture1 is pause,”
It doesn’t work at all. Interestingly, sometimes the button will toggle from normal (play) to pause on the first click, but won’t toggle back to normal on a second click.
My guess is that there is something I don’t understand about triggers in this case, but I can’t find the anywhere. If I can't do it this way, I'd REALLY love to know why. I'm someone who benefits from understanding how things work.
Thanks for any help you can offer.
- MichaelHinzeCommunity Member
I would simply add the "Pause" bitmap to the built-in Selected state and remove all triggers. With that the button will toggle between the built-in Normal and Selected states when clicked. See attached.
- PatrickFinne459Community Member
Thanks Michael, that worked. I didn't try that because I assumed (incorrectly) that the Selected state of an object was exclusive and would be cancelled if the learner clicked on another object, making that object selected.
- WaltHamiltonSuper Hero
Michael has suggested the best course.
To help you with future troubleshooting, walk slowly through the two triggers you suggested. Imagine the state is Normal when the learner clicks. According to your first trigger, the state will be changed to Pause. Now that it is in the Pause state, the second trigger will change it to Normal.
If you switch the order of the triggers, it will appear to be stuck in the pause state, for the same reason.
- PatrickFinne459Community Member
Thanks for the advice of walking through each trigger step slowly. I didn't catch that the second trigger would run right after the first. For some reason I was thinking that the trigger would determine which command to run based on the IF statement and run only the one that was "true."
Hi Patrick!
Thanks so much for reaching out.
I see that you've opened a case and you're working with my colleague Luiza. Great call, you're in good hands!
We'll continue the conversation over in the support case.
Have a great day and happy developing! ✨
- WaltHamiltonSuper Hero
You are correct that it only runs the triggers whose conditions are True. What traps a lot of people is that it runs them if they are true when that specific trigger is evaluated, without regard to what the condition was when the action is initiated.
You said:
I assumed (incorrectly) that the Selected state of an object was exclusive
You can make it work that way, if you want. Select some objects, right-click, and choose Button Set. For a set, only one can be in the Selected state at a time, and clicking a second automatically deselects the first.