-
-
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
Make mocking picking events for bevy_ui easier #17399
base: main
Are you sure you want to change the base?
Conversation
A concern I have is that the motivation, use case, and overall theory of operation won't be apparent to people who are looking at the docs for Pointer. I would like to see a more detailed note, and possibly link to the emulated pointer documentation. |
I have a lot of thoughts but I need some time to write them down. I've explored this space a lot at work, and there are some design problems I think we need to solve first to avoid backing ourselves into a corner. |
Objective
As discussed in #17267, we'd like to unify input-focus driven widget activations (e.g. press enter to click the focused button) with mouse-driven picking interactions by going through the bevy_picking infrastructure.
While you can fake this with observer triggers, it is:
Solution
As @aevyrie points out, we have access to everything we need to send realistic pointer events! Doing this correctly requires rather a lot of information. To make users lives easier, I've introduced a system param with all of the required information, which simulates pointer events at the center of the UI node specified.
The
directional_navigation
example has been updated to demonstrate / test this change.I've also removed the
Component
impl forbevy_picking::Location
as this is unused and a serious footgun: I wasted quite a bit of time trying to debug what had gone wrong. See #17390.Discussion
bevy_ui/picking_backend.rs
, but I've opted to defer that to make the diff easier to read.SystemParam
for flexibility, easier error handling and performance.SystemParam
to make certain actions even easier.Testing
I've tested this with the
directional_navigation
example. While I hope that this works properly with more exotic windowing / rendering target setups (viewports, portals, multiple windows), we're not equipped to do that effectively right now.Migration Guide
bevy_picking::Location
is no longer a component. This was a bug: you wantedPickingLocation
.PointerId
has a new variant,PointerId::Focus
that will need to be exhaustively matched against.