Manual Untoggle Texture Buttons

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By ondesic

I have a toogle TextureButton. It turns on an ability IF the player is level 19 or higher. The problem is, if the player is too low of level, I want to manually turn off the button. I have to use AbilityButton.pressed = false which then calls the toggled function again. Is there a way to catch the button toggled before it actually draws the PRESSED state, then manually turn the state to NORMAL, and cancel the event so it doesn’t call the toggled function at all?

:bust_in_silhouette: Reply From: Xian

just put all the code you used for toggle button in a if statement.
Say if player.level > 18: then all your codes under this if statement will only run if the player is level 19 and above, so even if the button is pressed, the button will do nothing unless the player is level 19 and above.

The problem is, by the time the code reaches the toggled function, the actual button has changed appearance.
Therefore, I have to manually change the toggled button state to false. By doing this, it calls the toggled function again.
I want to catch the button before it ever reached the Toggled signal to stop the appearance change at the very root of the event.

ondesic | 2019-11-06 22:06