Skip to content
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

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
PointerId::Focus
alice-i-cecile committed Jan 15, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit e373c51b9c1f49c86b2b3cfa8f30bce759f12a87
4 changes: 4 additions & 0 deletions crates/bevy_picking/src/pointer.rs
Original file line number Diff line number Diff line change
@@ -34,6 +34,10 @@ pub enum PointerId {
Mouse,
/// A touch input, usually numbered by window touch events from `winit`.
Touch(u64),
/// An emulated pointer linked to the focused entity.
///
/// Generally triggered by the `Enter` key or an `A` input on a gamepad.
Focus,
/// A custom, uniquely identified pointer. Useful for mocking inputs or implementing a software
/// controlled cursor.
#[reflect(ignore)]
3 changes: 1 addition & 2 deletions examples/ui/directional_navigation.rs
Original file line number Diff line number Diff line change
@@ -387,8 +387,7 @@ fn interact_with_focused_button(
commands.trigger_targets(
Pointer::<Pressed> {
target: focused_entity,
// We're pretending that we're a mouse
pointer_id: PointerId::Mouse,
pointer_id: PointerId::Focus,
// This field isn't used, so we're just setting it to a placeholder value
pointer_location: Location {
target: NormalizedRenderTarget::Image(