Forum Discussion

DougArnold-26e1's avatar
DougArnold-26e1
Community Member
4 months ago

Help needed with seemingly simple 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 included the file with this post. 

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've noticed that when I try editing the different states, there are triggers that appear where I can't delete them. Is this normal?