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?

asked Nov 16, 2019 in Engine by gubbebubbe (26 points)

1 Answer

+2 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?

answered Nov 16, 2019 by estebanmolca (1,201 points)
selected Nov 16, 2019 by gubbebubbe

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.