I have a pesky problem with the Checkbox. Everytime I code CheckBox.Pressed = true
, the Pressed event is fired. I simply want the appearance to change without triggering the on_CheckBox_pressed()
event. Is there a way to do this?
Change Checkbox pressed state without firing event?
disconnect the signal?
That may work but seems cumbersome. Any other ideas?
- Edited
You could add a bool variable, for example "pressed_via_code", and set it to true right before setting CheckBox.Pressed = true. Then you'd be able to check this bool within your event.
func _on_CheckBox_pressed():
if pressed_via_code:
pressed_via_code = false
return
else:
do_stuff()
Of course this will only work if you have the bool and the event within the same script. Otherwise you'll need a reference/connection to the corresponding script.
9 days later
Thanks, I'll try that
2 years later
Megalomaniak added the Godot Help tag .
5 months later
in Godot4 at least : checkbox.set_pressed_no_signal(your_bool_value)