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!

asked Feb 18 in Engine by SamTT (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.

answered Feb 18 by njamster (9,522 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 How to use this Q&A? before posting your first questions.