-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Reset cursor position after app update #3599
Reset cursor position after app update #3599
Conversation
Typically "resource state" is generated by processing all events since this update started in the order they arrive. The problem is that this "projection of event state" is lossy (ex: you cant find an intermediate position of the cursor, only the last position of the cursor). Resource state is provided as a way for users to query the "current state of a thing as of this frame" as a shorthand for regenerating the current state by processing events one by one. Up until now, if the intermediate state was required by the app, the solution was to consume events directly. Resource state == "easy to access and current as of this frame if you were to process all events in they order the arrived". Events == "harder to access current state, but gives you full access to the changes in the order they occur". This change breaks a number of the assumptions above:
If there is no other solution to this problem, I'm open to considering this. But I'd like to solve (1) and (2) if we can. |
This appears to be resolvable by just handling the "no cursor position" case properly in the interaction handler. I think I have a working solution. Just testing edge cases now. |
I think handling it in the interaction handler could work only if you don't care where the mouse is when you have the mouse_up event. |
I think thats already the case right? Isn't that desirable behavior? |
For drag and drop or selection, if you don't use the cursor position on button up, it means you have to keep an internat state of where the cursor was last seen. |
Hmm that might be something we want to provide then (we do already track this, so we could have a "last cursor position" on windows). Introducing information lag in the interest of specific scenarios feels wrong to me. |
I'll create a new PR that handles the "no cursor position" correctly in the interaction handler. It will also fix another bug on wasm that leaves the button pressed when a click press results in a scroll (present both in this PR and in my interaction fix). |
Objective
CursorLeft
events reset the cursor position immediatelySolution
pointerup
events, which winit uses to triggerMouseInput
events for mouse button up, are immediately followed by apointerout
event on browser that don't support the "hover"bevy_ui
andbevy_egui
) react on mouse button up events