Topic was automatically imported from the old Question2Answer platform.
Asked By
MaaaxiKing
I have multiple Buttons with “pressed” signals in my scene. I want to print the name of the button that was pressed or the name of the _on_Button_pressed() function of the pressed button but not with
Hi,
There may be other ways, but you can:
Add a button.
In the button Signals section, add a signal for pressed.
Make the Receiver Method: _on_Button_pressed
Click Advanced
Add an extra call argument of String or Int and put in the value “Button1” or 1
Click connect.
Repeat that for the rest of your buttons.
All buttons will go to the same function, where you can handle the button press:
It’s for static typing. If you are returning a value, then you need to change it from void to the type of what you are returning.
It helps when you are coding, to make sure your functions return what they are or are not supposed to.