-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix unrestricted mouse-event propagation to SubViewports for Physics-Picking #57894
Conversation
7bc5bd8
to
c42a242
Compare
c42a242
to
a889de8
Compare
a889de8
to
daec59f
Compare
daec59f
to
eb00d42
Compare
eb00d42
to
7a8b031
Compare
7a8b031
to
794b17a
Compare
This solves the problem, that mouse events get sent to SubViewports even if they are outside of the visible area of the SubViewport. This changes makes SubViewportContainer::unhandled_input redundand. Shortcut Events now need to be distributed via push_input, in order for them to be able to reach SubViewports.
794b17a
to
8836f21
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested the attached project + some random stuff and it appears to be working correctly.
I think it's a good time to merge this. |
Thanks! |
I commented already in #17326, but I think some or much of this PR may be missing from the latest beta, 4.2.beta5. At least, I looked at the code and it seemed like some of it was missing - could be it was updated in the future and I missed that. |
@WolfgangSenff The only thing, that changed, was the renaming of |
resolve #17326
resolve #58902
resolve #75015
resolve #75019
previous description
Currently, Events get processed by Nodes in order of the green arrow in the following graphic, when a
SubViewportContainer
is within the Root Viewport:The red "X" denotes the place where
set_input_as_handled()
is called withinViewport::_gui_input_event
, when anInputEventMouseMotion
happens over theSubViewportContainer
. Here is the according location in the source code:godot/scene/main/viewport.cpp
Lines 1789 to 1796 in 84f2c68
If the
SubViewportContainer
marks the event as stopped,_unhandled_input
is never called.If the
SubViewportContainer
ignores the event, it is processed in_unhandled_input
, even though ignoring should be a synonym for not sending the event to the SubViewport of SubViewportContainer.This pull request makes sure, that the event reaches _unhandled_input inside the SubViewport before the "X":
This is done by moving the
push_unhandled_input
call fromWindow::_window_input
toViewport::push_input
.This change makes
SubViewportContainer::unhandled_input
redundant, since it would distribute the event to _unhandled_input inside the SubViewport a second time.Shortcut Events now need to be distributed via
push_input
, in order for them to be able to reachSubViewports
.MRP for all linked issues: SubViewportEventBugs.zip
Currently InputEvents get sent unconditionally to
SubViewports
viaSubViewportContainer::unhandled_input
, even if the event-position is outside of the area of theSubViewportContainer
. This leads to problems like #58902, where the mouse entersCollisionObjects2D
, even if they are not visible. (in the MRP, clicking in the red area causes a mouse-click on the non-visible Logo within theSubViewport
).Also hovering
CollisionObjects2D
withinSubViewports
currently is reversed:SubViewportContainer
is set toMOUSE_FILTER_IGNORE
, theCollisionObject2D
does receive mouse events.SubViewportContainer
is set toMOUSE_FILTER_STOP
, theCollisionObject2D
doesn't receive mouse events.A third bug is that a Panel with
MOUSE_FILTER_STOP
, parent of a SubViewportContainer, prohibits Physics-picking in the SubViewport.The fourth bug, that gets fixed is that TouchScreenButtons don't receive some mouse events within
_unhandled_input
. (TouchScreenButton doesnt send event via _unhandled_input)This PR solves all problems by moving the call of
push_unhandled_input
fromWindow::_window_input
toViewport::push_input
.This makes sure, that only events with a position within the area of the
SubViewportContainer
are considered for physics picking.This change makes
SubViewportContainer::unhandled_input
redundant, since it would distribute the event to _unhandled_input inside the SubViewport a second time.Updated 2022-09-26: fix merge conflict, made sure that this PR is still relevant after #61088 and adjusted description.
Updated 2022-10-14: adjust shortcut event handling
Updated 2022-11-06: update documentation of
push_input
.Updated 2022-11-23: fix merge conflict
Updated 2023-01-27: fix merge conflict, update description based on the recently merged #58334
Updated 2023-03-17: fix merge conflict, updated MRP, linked a third bug, that this PR fixes.
Updated 2023-05-08: linked a fourth bug, that this PR fixes and updated description and MRP.