Godot Version
4.3 stable
Question
I find Viewport.set_input_as_handled() is not work for CollisionObject2D._input_event(), but i need the event is control by sence tree order
Is any best practices here?
4.3 stable
I find Viewport.set_input_as_handled() is not work for CollisionObject2D._input_event(), but i need the event is control by sence tree order
Is any best practices here?
That’s because set_input_as_handled()
handles the Input FIRST so it doesn’t propagate, it doesn’t stop it from happening, it will still execute.
If you want to kill all mouse inputs, use return
If event is InputEventMouseMotion:
return
not kill all mouse inputs, just A`s.
In my expectation, B should response the event, and stop it, so A will not response the same event, when mouse into the cover area
Are you using the same script for both nodes?
Because I can see you are, which means the same input will not be stopped from executing on the other.
Yes same script both
But its my expect, i need two same node, just top node(that position at the back of the sence tree) response mouse event
What if you tried to use the provided viewport
from the function arguments instead of get_viewport()
to set the event as handled?
I’m on mobile, so can’t test it myself.
I have already tried it, its not work too
I have discovered a new case
its seem not a bug of Viewport.set_input_as_handled(). its a bug of _input_event() excution order.
If i click the overlapping area many times. I can see A or B response click, and just print once, but whether A or B corresponds to the clicking action is not regular
I got the key! It’s really hard to detect.
I got it from Github, i think just the contributors knows