This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
+2 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 (29 points)

1 Answer

+5 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 (2,260 points)
selected by

I understand now. Thank you!

It solved the problem for me, thanks!

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 Frequently asked questions and 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 [email protected] with your username.