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(): createbutton()
func createbutton(): btn = Button.new() btn.set_name("button 1") btn.text = "button 1" hbox_container.add_child(btn) 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") else: print("Button is released")
extends PanelContainer
onready var hbox_container = $ScrollContainer/HBoxContainer
var btn
func _ready():
createbutton()
func createbutton():
btn = Button.new()
btn.set_name("button 1")
btn.text = "button 1"
hbox_container.add_child(btn)
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")
else:
print("Button is released")