Make mocking picking events for bevy_ui easier#17399
Closed
alice-i-cecile wants to merge 16 commits intobevyengine:mainfrom
Closed
Make mocking picking events for bevy_ui easier#17399alice-i-cecile wants to merge 16 commits intobevyengine:mainfrom
alice-i-cecile wants to merge 16 commits intobevyengine:mainfrom
Conversation
3 tasks
Contributor
|
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. |
Member
|
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. |
Member
Author
|
Just got off a call with @aevyrie on this topic: https://hackmd.io/swhNP8IYTmGqCOOkyfUFFA I'm going to draft this PR for now, do the refactor for PointerId in another PR, and then come back and merge this. |
Member
Author
|
Needs to be redone / rethought. Closing. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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_navigationexample has been updated to demonstrate / test this change.I've also removed the
Componentimpl forbevy_picking::Locationas 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.SystemParamfor flexibility, easier error handling and performance.SystemParamto make certain actions even easier.Testing
I've tested this with the
directional_navigationexample. 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::Locationis no longer a component. This was a bug: you wantedPickingLocation.PointerIdhas a new variant,PointerId::Focusthat will need to be exhaustively matched against.