Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | servitor | |
Old Version | Published before Godot 3 was released. |
I have created a custom control node that I am using as part of my GUI. It takes input as follows:
func _input_event(event):
if (event.type == InputEvent.MOUSE_BUTTON):
if (event.pressed):
print("control mouse button pressed")
active=true
accept_event()
else:
print("control mouse button released")
active=false
elif (active and event.type == InputEvent.MOUSE_MOTION):
print(event.relative_pos)
I then have an area 2d node that is processing input as follows:
func _input(event):
if (event.type == InputEvent.MOUSE_BUTTON):
if (event.pressed):
print("area 2d mouse button pressed")
get_tree().set_input_as_handled()
In this scenario, I would expect that clicking inside of the control node would produce the output “control mouse button pressed” and “control mouse button released” and then nothing else since I am accepting the event and control nodes are supposed to receive events first. Instead, I get:
area 2d mouse button pressed
control mouse button pressed
control mouse button released
My understanding was that control nodes receive events first and can accept those events causing them to not be passed on to other nodes. Why is the area 2d node receiving the input event first? Am I misunderstanding this or should I be handling events a different way?