-
-
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
Add a simple directional UI navigation example #17224
base: main
Are you sure you want to change the base?
Add a simple directional UI navigation example #17224
Conversation
thread 'main' panicked at C:\Users\alice\.cargo\registry\src\index.crates.io-Panic was: 6f17d22bba15001f\accesskit_consumer-0.26.0\src\tree.rs:34:13: Focused id #4294967304 is not in the node list
The generated |
cargo run -p build-templated-pages -- update examples
Sent a couple tiny PRs your way |
Fix centering of buttons and their contents
…tton Fix enter button and change background color instead of printing
} | ||
} | ||
|
||
// We're spawning a simple 3x3 grid of buttons |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// We're spawning a simple 3x3 grid of buttons | |
// We're spawning a simple 3x5 grid of buttons |
// Allow the grid to take up the full height and width of the window | ||
width: Val::Percent(60.), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO
- Make instructions node wider, maybe
Px(300.0)
- Leave this at
100.0
. - Adjust this comment to say "take up the full height and the rest of the width."
Seems okay for the grid to not be centered in the screen to me.
// to capture the actual intent of the user | ||
fn universal_button_click_behavior( | ||
// We're using a on-mouse-down trigger to improve responsiveness; | ||
// Clicked is better when you want roll-off cancellation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be nicer to have separate effects that get triggered on Pressed
and Clicked
rather than explain why it looks like we're doing the "wrong" thing.
But that could be a future improvement.
width: Val::Px(200.0), | ||
justify_content: JustifyContent::Center, | ||
align_items: AlignItems::Center, | ||
margin: UiRect::all(Val::Px(16.0)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
margin: UiRect::all(Val::Px(16.0)), | |
margin: UiRect::all(Val::Px(12.0)), |
For consistency with other examples with top-left instructions
Checked and working with an 8Bitdo Ultimate on Linux. D-pad and left stick both navigate, I presume because of whatever mode the controller is in. |
b00e303
to
e5d7cda
Compare
Objective
Gamepad / directional navigation needs an example, for both teaching and testing purposes.
Solution
To do: this PR
fix colors not resetting on button presslol this is mostly just a problem with hackingInteraction
for thisInteraction
To do: future work
Text2d
andTextSpan
is not center-aligned whenJustifyText::Center
is specified. #16783add_edges
method toDirectionalNavigationMap
add_grid
method toDirectionalNavigationMap
Testing
cargo run --example directional_navigation