0 votes

How we can get the button reference on the event function that is connected?
My connect signals never works

extends PanelContainer

onready var hbox_container = $ScrollContainer/HBoxContainer
var btn 

func _ready():

func createbutton():
    btn = Button.new()
    btn.set_name("button 1")
    btn.text = "button 1"
    btn.connect("toggled", self, "button_toggled", [btn])

func button_toggled(toggled, target):
    print("which button = ", target.get_name())
    if toggled == true:
        print("Button ist pressed")
        print("Button is released")

Any way at least to do this? Thank you very much!

in Engine by (28 points)

1 Answer

+1 vote

Check out this question. As far as I know, it's not possible from the GUI, but it can be easily achieved via scripting. An example script is provided in the linked question.

by (10,580 points)

it works!
Thank you very much :)

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.