From f04c0ef68927edc40cd1c3a4479b80b9e0c9ca7c Mon Sep 17 00:00:00 2001 From: ickshonpe Date: Mon, 26 May 2025 21:20:00 +0100 Subject: [PATCH] `tab_navigation` example improvements (#19239) # Objective Improve the `tab_navigation` example. ## Solution * Set different `TabIndex`s for the buttons of each group. * Label each button with its associated `TabIndex`. * Reduce the code duplication using a loop. I tried to flatten it further using the new spawning APIs and `children!` macro but not sure what the current best way to attach the observers is. --- examples/ui/tab_navigation.rs | 192 +++++++++++----------------------- 1 file changed, 62 insertions(+), 130 deletions(-) diff --git a/examples/ui/tab_navigation.rs b/examples/ui/tab_navigation.rs index 0924269353..25e43cf0be 100644 --- a/examples/ui/tab_navigation.rs +++ b/examples/ui/tab_navigation.rs @@ -26,31 +26,21 @@ const PRESSED_BUTTON: Color = Color::srgb(0.35, 0.75, 0.35); fn button_system( mut interaction_query: Query< - ( - &Interaction, - &mut BackgroundColor, - &mut BorderColor, - &Children, - ), + (&Interaction, &mut BackgroundColor, &mut BorderColor), (Changed, With