-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Remove Option
from any cursor position API
#8865
Comments
I think it's supposed to represent the cursor being outside of the window.
I added a line in #8858 for
I think it's not supposed to happen. If it happened to you it might be linked to this bug: #8840 |
Thanks @Selene-Amanita for the docs. I approved your PR. I still think that |
We don't get cursor position updates outside of the window from winit, so to implement this we'd have to manually track cursor position using
This is a separate issue that is being solved in #8852. I feel like this is being too extreme and better solved by improving the API surfaces in other areas. Something that would be helpful is seeing examples of what you are trying to do here and why this is a pain. For example it might be a good idea to add a |
Yes that was my initial reaction. But then I remembered |
About what I'm trying to do:
|
What problem does this solve or what need does it fill?
I'm trying to write a simple UI for some example. Nothing fancy. I keep hitting a wall against all the cursor position APIs returning an
Option<Vec2>
.None
ever possible? This is documented nowhere. What does it ever mean to get anInteraction::Clicked
with aNone
mouse cursor position?None
. This leaks into all code dealing with UI: button click, drag and drop, etc. and there's no good behavior to assign to it.What solution would you like?
Remove the
Option
from all those APIs, just useVec2
directly. If there's really a case where the mouse cursor position is not available, document why and possibly add an escape hatch for handling that, our try our best guess to find a position anyway.What alternative(s) have you considered?
User has to wrap all APIs into their own helper function(s) to safely unwrap that
Option
or find a default based on the (primary) window and other factors, which systematically adds several queries to all systems and is far from trivial (see Additional context).Additional context
Interaction
has no cursor information on clickRelativeCursorPosition
stores anOption<Vec2>
but it's unused for cases where the cursor is outside the widget, which would be the only case where I find this would make sense.The text was updated successfully, but these errors were encountered: