1
\$\begingroup\$

Currently i have three buttons that can be toggled with only one being active at once. When one button is selected by the player it sends a signal to the other two buttons to toggle off. Before the recent Godot update this set up worked fine, but now when the player toggeles a button on, the button thats being turned off now sends its toggeled signal thus turning off the very button the player clicked.

So im looking for a way to block a signal in code to prevent this loop.

Code for reference:

Player button:

func _on_Ally1_Button_toggled(button_pressed,check):
    print("on ally1 toggeled P")
    self.set_pressed(false)


func _on_Ally2_Button_toggled(button_pressed,check):
    print("on ally2 toggeled P")
    self.set_pressed(false)

Ally1 Button:

 func _on_Player_Button_toggled(button_pressed,check):
    print("on player toggeled A1")
    self.set_pressed(false)


 func _on_Ally2_Button_toggled(button_pressed,check):
    print("on ally2 toggeled A1")
    self.set_pressed(false)

Ally2 Button:

 func _on_Player_Button_toggled(button_pressed,check):
    print("on player toggeled A2")
    self.set_pressed(false)


func _on_Ally1_Button_toggled(button_pressed,check):
    print("on ally1 toggeled A2")
    print(check)
    self.set_pressed(false)

The check varible being passed in is how i plan stop the loop i just need a way stop signal.

Thank you in advance for the help.

\$\endgroup\$

1 Answer 1

4
\$\begingroup\$

Forget about all these signals, and just use a ButtonGroup. When multiple buttons have the same ButtonGroup assigned to their group field, Godot will only allow one to be toggled on at once.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .