Godot Version
Godot 4.2.2
Question
Hello!
I’m trying to create a dynamic set of cards (texture_buttons), and I’d like to have different behaviors when left or right clicking the cards. Since the cards are dynamically created and added to the tree, I’m also connecting a signal dynamically, but it doesn’t seem to work. It used to work when the signal was simply “pressed” instead of “gui_input”, sadly I don’t really get how to work with gui_input that well.
It’s important that I get to pass the texture_button itself to the function, to retrieve its information like the texture itself, text and etc…
Here’s my code! Nothing gets printed, not even the first one which means the function is never once entered.
texture_button.connect("gui_input", Callable(self, "on_card_pressed").bind(InputEventMouseButton, texture_button))
func _on_card_pressed(event, button: TextureButton):
print("I'm in!")
if event is InputEventMouseButton and event.is_pressed():
match event.button_index:
MOUSE_BUTTON_LEFT:
print("left")
MOUSE_BUTTON_RIGHT:
print("right")
var image_path = button.get_texture_normal().resource_path
print(image_path)