Skip to content

Conversation

@kfc35
Copy link
Contributor

@kfc35 kfc35 commented Jan 6, 2026

Objective

Solution

  • Creates a new example called navigation (examples/ui/navigation.rs) that demonstrates both auto navigation and manually defining/overriding edges via the DirectionalNavigationMap. The example basically copies code from the purely auto navigation example (examples/ui/auto_directional_navigation.rs) as a base, changes the grid of buttons in the middle, and adds the manual map configuration.

Testing

  • The example runs fine! cargo run --example navigation.
  • Horizontal navigation within a row is configured automatically
  • Horizontal navigation between rows is configured manually so that it sort of spirals (Row 1 Button 3 + Right = Row 2 Button 1)
  • Vertical navigation between rows is configured manually. Its controls are inverted (pressing up goes down) and the navigation wraps (pressing up on a button in bottom most row navigates to the relevant button in top row and vice versa)

Showcase

Screen Recording
Screen.Recording.2026-01-06.at.4.29.42.PM.mov

Copy link
Contributor

@it-me-joda it-me-joda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that I personally would rather have each navigation mode in a separate example. Then maybe a third that demonstrates that you could combine them? This current state is overwhelming at first glance. I think I would have examples like:

ui/navigation/
    auto-navigation
    manual-navigation
    combined-navigation

But that's just my personal opinion. I'd be curious to see what others think about it.

@alice-i-cecile alice-i-cecile added C-Examples An addition or correction to our examples A-UI Graphical user interfaces, styles, layouts, and widgets S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jan 7, 2026
@alice-i-cecile
Copy link
Member

I agree with @it-me-joda here, with the emphasis in the third example focusing on how and why to use overrides.

@alice-i-cecile alice-i-cecile added S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jan 7, 2026
@kfc35 kfc35 marked this pull request as draft January 7, 2026 19:14
highlight_focused_element,
interact_with_focused_button,
reset_button_after_interaction,
update_focus_display,
Copy link
Contributor

@ickshonpe ickshonpe Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Text updates are expensive, so better to only update the labels on changes:

Suggested change
update_focus_display,
update_focus_display.run_if(|input_focus: Res<InputFocus>| input_focus.is_changed()),,

It's not that much text, but atm there is a bug where a new font is created every text update (#22419). After leaving the example running for a while, you'll see a significant delay in moving the cursor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-UI Graphical user interfaces, styles, layouts, and widgets C-Examples An addition or correction to our examples S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bevy_input_focus: No example demonstrates how to use the DirectionalNavigationMap and automatic navigation together

4 participants