-
-
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
Expose a CursorPosition
resource
#5034
Comments
We probably want to also record which window the mouse position is associated with, and iterate through all of the windows to check if it's on any of the open windows. |
MousePosition
resourceCursorPosition
resource
right now, such a resource would be equivalent to the resources |
The ergonomics and discoverability of that solution are really poor though. Every time i need to do these or to teach someone how to do this I need to link to the Cheatbook page. This solution would also be robust to those changes, which would provide a nicer migration path. |
Hi! I was just wondering if this issue has been resolved or not? |
Has not been resolved, but Francois's workaround still works :) I'd be happy to review a PR that tackled this before #4530, as that work is shockingly complex. |
Ok, so the best option would probably be to wait for #4530 to be resolved. I have never contributed before, but If there is anything that I could possibly try and improve upon then I would like to give it a try. |
I don't think this can be closed: instead, it's no longer blocked. |
I'm currently implementing "ExtractResource" for a "MousePosition" struct, but given that the "Windows" resource is no longer a resource, I cannot put "Windows" as the associated type of the ExtractResource trait anymore which kind of hurts my feelings (I'm following #6550 to fiddle with compute shaders) |
What problem does this solve or what need does it fill?
Knowing where your mouse is is useful and should be ergonomic.
What solution would you like?
Store and update a
CursorPosition
resource, which reads from theWindow
resource to store anOption<Vec2>
representing the physical position of the mouse (or other cursor).What alternative(s) have you considered?
Compute this manually every time it's needed.
Additional context
This will be impacted by #4530, which will move where this data is stored.
Better APIs to convert between world space and screen space coordinates will make this functionality even more useful; we should add methods on
MousePosition
to do this once those are established.The text was updated successfully, but these errors were encountered: