Skip to content

Commit

Permalink
Rename clicked interaction to pressed
Browse files Browse the repository at this point in the history
  • Loading branch information
0HyperCube committed Jul 20, 2023
1 parent 15f19dc commit 7e7795a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions crates/bevy_ui/src/keyboard_navigation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ use bevy_ecs::query::With;
use bevy_ecs::system::{Local, Query, Res, ResMut, Resource};
use bevy_ecs::{change_detection::DetectChangesMut, entity::Entity};
use bevy_input::{prelude::KeyCode, Input};
use bevy_reflect::{FromReflect, Reflect};
use bevy_reflect::Reflect;
use bevy_render::view::ComputedVisibility;

/// A component that represents if a UI element is focused.
#[derive(Reflect, FromReflect, Component, Clone, Debug, Default, Eq, PartialEq)]
#[derive(Reflect, Component, Clone, Debug, Default, Eq, PartialEq)]
pub struct Focusable {
focus_state: FocusState,
}
Expand All @@ -28,7 +28,7 @@ impl Focusable {
}
}

#[derive(Reflect, FromReflect, Clone, Debug, Default, Eq, PartialEq)]
#[derive(Reflect, Clone, Debug, Default, Eq, PartialEq)]
enum FocusState {
/// Entity is not focused
#[default]
Expand Down Expand Up @@ -113,7 +113,7 @@ pub(crate) fn keyboard_navigation_system(
.entity
.and_then(|entity| interactions.get_mut(entity).ok())
{
if *interaction == Interaction::Clicked {
if *interaction == Interaction::Pressed {
*interaction = Interaction::None;
}
}
Expand Down Expand Up @@ -169,7 +169,7 @@ pub(crate) fn keyboard_click(mut interactions: Query<&mut Interaction>, focus: R
.entity
.and_then(|entity| interactions.get_mut(entity).ok())
{
interaction.set_if_neq(Interaction::Clicked);
interaction.set_if_neq(Interaction::Pressed);
}
}

Expand All @@ -181,7 +181,7 @@ pub(crate) fn trigger_click_end(keyboard_input: Res<Input<KeyCode>>) -> bool {
/// Reset the clicked state.
pub(crate) fn end_keyboard_click(mut interactions: Query<&mut Interaction>) {
interactions.for_each_mut(|mut interaction| {
if *interaction == Interaction::Clicked {
if *interaction == Interaction::Pressed {
// The click was triggered by the keyboard, so it doesn't make sense to go to `Interaction::Hovered`.
*interaction = Interaction::None;
}
Expand Down
4 changes: 2 additions & 2 deletions examples/ui/keyboard_navigation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ fn update_button_style(
) {
for (interaction, mut color) in &mut interaction_query {
*color = match *interaction {
Interaction::Clicked => PRESSED_BUTTON,
Interaction::Pressed => PRESSED_BUTTON,
Interaction::Hovered => HOVERED_BUTTON,
Interaction::None => NORMAL_BUTTON,
}
Expand All @@ -68,7 +68,7 @@ fn button_trigger(
mut counter: ResMut<Counter>,
) {
for (interaction, counter_change) in &mut interaction_query {
if matches!(interaction, Interaction::Clicked) {
if matches!(interaction, Interaction::Pressed) {
match counter_change {
CounterChange::Add => counter.0 += 1,
CounterChange::Subtract => counter.0 -= 1,
Expand Down

0 comments on commit 7e7795a

Please sign in to comment.