Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | edpmath |
I have this code in a Node2D scene:
func _unhandled_input(event):
print("Runner@UnhandledInput")
print (event.as_text())
if event is InputEventMouseButton:
if event.button_index == BUTTON_LEFT:
if event.pressed:
print("Mouse event")
elif event.pressed and event.scancode == KEY_ESCAPE:
get_tree().quit()
My output if i push a keyboard key (up):
Runner@UnhandledInput Up
Runner@UnhandledInput Up
But if i make a click, i have not any output, i am not marking NOTHING as handled, so i don’t understand why my proccesor is’nt listening mouse events.
Do you have a control node or something else catching the event? What’s your scene layout?
exuin | 2021-01-15 20:27
No, i did move every input listener to a unique controller (master node in one scene), but i have buttons.
My tree is:
- Runner (Node)
---- Background (Linked, no have listeners)
----GUI (Linked, Node, have 2 buttons)
---- Character (Linked, no have listener)
My problem starts with the pause button, my character jump with any click, and when i push pause he was jumping, now, with _unhandled_input the touch or click isn’t listening
edpmath | 2021-01-15 23:32
Does your GUI cover the entire screen? It might be taking the click event that way. You’ll need to set the mouse filter to ignore if that’s the case.
exuin | 2021-01-16 00:09
Effectively. My UI Control Main node is fullscreen, i setup his mouse property to ignore and now my buttons works propertly and my character jump perfectly. Very thanks!!
edpmath | 2021-01-16 00:17