-
-
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
Open
alice-i-cecile
wants to merge
16
commits into
bevyengine:main
Choose a base branch
from
alice-i-cecile:mocking-picking
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alice-i-cecile
added
A-Input
Player input via keyboard, mouse, gamepad, and more
A-UI
Graphical user interfaces, styles, layouts, and widgets
C-Usability
A targeted quality-of-life change that makes Bevy easier to use
M-Needs-Migration-Guide
A breaking change to Bevy's public API that needs to be noted in a migration guide
D-Modest
A "normal" level of difficulty; suitable for simple features or challenging fixes
S-Needs-Review
Needs reviewer attention (from anyone!) to move forward
A-Picking
Pointing at and selecting objects of all sorts
labels
Jan 16, 2025
3 tasks
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. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-Input
Player input via keyboard, mouse, gamepad, and more
A-Picking
Pointing at and selecting objects of all sorts
A-UI
Graphical user interfaces, styles, layouts, and widgets
C-Usability
A targeted quality-of-life change that makes Bevy easier to use
D-Modest
A "normal" level of difficulty; suitable for simple features or challenging fixes
M-Needs-Migration-Guide
A breaking change to Bevy's public API that needs to be noted in a migration guide
S-Needs-Review
Needs reviewer attention (from anyone!) to move forward
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.