0 votes

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?

in Engine by (26 points)

1 Answer

+3 votes
Best answer
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?

by (1,712 points)
selected by

I understand now. Thank you!

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.

Categories