-
-
Notifications
You must be signed in to change notification settings - Fork 22k
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
Keep input event as unhandled if they go through a control set to MOU… #61088
Keep input event as unhandled if they go through a control set to MOU… #61088
Conversation
Ah wait, it seems there's a bug with release events, which might not end up in |
c84179b
to
56ae2b8
Compare
Alright, I had to modify the PR to avoid some issues but it made me discovered other. See the original post. |
f5ddf5b
to
cbc43d6
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.
Approved in PR review meeting. There's potential for regression but we'll find out in production ;) it's easy to see when input breaks.
cbc43d6
to
6db8b76
Compare
Alright, I updated the code with the suggested changes and updated the documentation accordingly. |
Well, I relied on what you said on that PR: #57894, where you said that "Since the event is internally marked as handled, _unhandled_input is never called.". This PR does make it so that event is passed to to But maybe I am wrong, I don't know, I haven't checked whether or not the PR solved the issue. Edit: to be clear, it does not mean your fix is not good. My PR may solve this specific issue but your changes might still be needed, I am not sure. |
Boolean arithmetic ... You are right, I misread your code. This PR might change the event behavior, so that the symptom which causes #17326, is mitigated. I believe, that #57894 is still necessary. With your changes applied I can provide a use-case where Mouse-clicks now are used up by a Control-Element, that is located behind a |
Yeah that makes sense. |
Thanks! |
I just tested this with my latest problem example in Godot 4.0 Alpha 11 and the Detailed issue description: #55432 (comment) |
I had that issue where I wanted to be able to drag&drop things onto a game view. To do so, I tried put a control set to MOUSE_FILTER_PASS on top of my world, expecting that all unhandled mouse event would end up being processed by
_unhandled_event
, turned out it wasn't the case. Basically, as soon as an event is given to a Control somewhere, the event would be considered as handled if it went through a control with MOUSE_FILTER_PASS or MOUSE_FILTER_STOP.However, I think it is not expected that an event which went through Controls set to MOUSE_FILTER_PASS ends up as handled if it wasn't explicitly set as handled.
As a consequence, what this PR does is simply set a mouse event as handled only if it it was stopped by a control. If the event reaches the root going only through controls set to MOUSE_FILTER_PASS or MOUSE_FILTER_IGNORE (and is not set as handled explicitly), then the event is now passed to the
_unhandled_event
processing.Obsolete edit
while investigating this issue, I ended up with other problems that I tried to fix too:_gui_call_input(...)
:Theev.is_valid()
part was always true, which caused all events, even keyboard ones, to be stopped while climbing up the tree if the Control had the filter set toMOUSE_FILTER_STOP
. This does not seemed like an intended behavior._unhandled_input
, but with this PR, it became quite annoying. So I removed this special case (as ScrollContainer is already set toMOUSE_FILTER_PASS
by default anyway). It is debatable whether or not this change is welcome, as it means that we would need all containers in a hierarchy to be set as to use theMOUSE_FILTER_IGNORE
orMOUSE_FILTER_PASS
modes so that the event can climb up the tree. Maybe an alternative would be to add another mode, set by default, that would allow those specific events to pass? LikeMOUSE_FILTER_STOP_BUT_SCROLLS
(bad name, I have to admit ^^)?Alright, I had to modify a little bit the PR:
_unhandled_input
. This initial work caused issues, as scroll events were always passed, even with theMOUSE_FILTER_STOP
filter. (I had no way to stop those events, thus scrolling in a ScrollContainer caused the event to be handled by_unhandled_input
, and, in my case, it caused my camera to zoom in/out)mouse_force_pass_scroll_events
. It allows you to still allow scroll events to be passed up the tree even when using theMOUSE_FILTER_STOP
filter. It is enabled by default. The property is grayed out if the mouse filter is not set toMOUSE_FILTER_STOP
as it is useless in those other cases.bool ismouse = ev.is_valid() || Object::cast_to<InputEventMouseMotion>(*p_input) != nullptr;