-
Notifications
You must be signed in to change notification settings - Fork 125
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 scrollbars when pointer capture is released #858
base: main
Are you sure you want to change the base?
Conversation
This PR does what you intended for it to do. However, the behavior isn't how users may expect it to work. For example, if I drag a scrollbar in a web browser, I can keep holding the click while dragging outside of the window, and the scrollbar will continue to follow my cursor on the appropriate axis. Would the current design allow for dragging while the cursor is outside of the window, or would further changes be required to make that work? |
This isn't the behaviour on my machine. As far as I know, this is how we describe this in the API we have now. |
That seems like an oversight on our part. A widget should only be able to release its own capture status. |
Testing both the main branch and this PR, I agree that our current model of pointer capture doesn't work, and especially the fact that we remove capture on PointerLeave. Honestly I'm not sure I had a good model of how winit worked when I coded that. I think I was thinking of This PR works as a band-aid to be less inconsistent in this case, but we'd probably want to keep pointer capture even when the pointer leaves the window rect. |
PointerEvent::PointerUp(_, _) => { | ||
PointerEvent::PointerUp(_, _) | PointerEvent::PointerLeave(_) => { | ||
self.grab_anchor = None; | ||
ctx.request_render(); | ||
} |
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.
At this point I wonder if we should add an Update::PointerCaptureChanged
event.
I think the relevant event is most likely I'm happy to close this if you don't think it's an improvement. |
Let's leave it open. We'll merge it if we haven't had a better fix before the end of the month. |
Fixes #857
cc @PoignardAzur - I don't know that the model for pointer capture is entirely coherent from a widget's perspective at the moment. In particular, since any widget can call
release_pointer
at any time, and there's no way for the widget with pointer capture to know.I'm also not certain that other widgets don't have this same issue. I do think something in our model might need to be refined slightly here.