Buttons with Toggle Mode signal mouse clicks rather than the buttons toggle?

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

I have a button with Toggle Mode enabled:

func _on_toggle_button_down() -> void:
    	print("hello")
	

func _on_toggle_button_up() -> void:
	print("goodbye")

When I click and release the mouse on the button, both hello and goodbye gets printed.

What I want is to print hello when the button is clicked (toggled), and print goodbuy when the button is untoggled

There is a “toggled” signal available however, it doesnt diffirentiate if its toggled ON or OFF .

Is this a bug, or am I doing something wrong?

:bust_in_silhouette: Reply From: estebanmolca
func _on_Button_toggled(button_pressed):
	if(button_pressed):
		print("Hello")
	else:
		print("Goodbye")	

The signal toggled has a bool parameter that can be used (button_pressed)
This is the behavior you expect?

I understand now. Thank you!

gubbebubbe | 2019-11-16 08:55

It solved the problem for me, thanks!

Wolf6Dev | 2021-09-12 17:23