MCPcopy Create free account
hub / github.com/LarsDu/StarRust / button_system

Function button_system

src/menus/mod.rs:83–97  ·  view source on GitHub ↗

This system handles changing all buttons color based on mouse interaction

(
    mut interaction_query: Query<
        (&Interaction, &mut BackgroundColor, Option<&SelectedOption>),
        (Changed<Interaction>, With<Button>),
    >,
)

Source from the content-addressed store, hash-verified

81}
82// This system handles changing all buttons color based on mouse interaction
83fn button_system(
84 mut interaction_query: Query<
85 (&Interaction, &mut BackgroundColor, Option<&SelectedOption>),
86 (Changed<Interaction>, With<Button>),
87 >,
88) {
89 for (interaction, mut color, selected) in &mut interaction_query {
90 *color = match (*interaction, selected) {
91 (Interaction::Pressed, _) | (Interaction::None, Some(_)) => PRESSED_BUTTON.into(),
92 (Interaction::Hovered, Some(_)) => HOVERED_PRESSED_BUTTON.into(),
93 (Interaction::Hovered, None) => HOVERED_BUTTON.into(),
94 (Interaction::None, None) => NORMAL_BUTTON.into(),
95 }
96 }
97}
98
99fn menu_action(
100 interaction_query: Query<

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected