diff --git a/crates/bevy_ui/src/focus.rs b/crates/bevy_ui/src/focus.rs index 06889ead589e7..fab9a0121c1a7 100644 --- a/crates/bevy_ui/src/focus.rs +++ b/crates/bevy_ui/src/focus.rs @@ -63,7 +63,7 @@ pub enum FocusPolicy { } impl FocusPolicy { - const DEFAULT: Self = Self::Block; + const DEFAULT: Self = Self::Pass; } impl Default for FocusPolicy { @@ -164,9 +164,7 @@ pub fn ui_focus_system( // Reset their interaction to None to avoid strange stuck state if let Some(mut interaction) = node.interaction { // We cannot simply set the interaction to None, as that will trigger change detection repeatedly - if *interaction != Interaction::None { - *interaction = Interaction::None; - } + interaction.set_if_neq(Interaction::None); } return None; diff --git a/crates/bevy_ui/src/node_bundles.rs b/crates/bevy_ui/src/node_bundles.rs index 8fd7d49f99cb2..8369b33bfe0b0 100644 --- a/crates/bevy_ui/src/node_bundles.rs +++ b/crates/bevy_ui/src/node_bundles.rs @@ -96,7 +96,7 @@ pub struct ImageBundle { } /// A UI node that is text -#[derive(Bundle, Clone, Debug)] +#[derive(Bundle, Clone, Debug, Default)] pub struct TextBundle { /// Describes the size of the node pub node: Node, @@ -160,25 +160,8 @@ impl TextBundle { } } -impl Default for TextBundle { - fn default() -> Self { - TextBundle { - focus_policy: FocusPolicy::Pass, - text: Default::default(), - node: Default::default(), - calculated_size: Default::default(), - style: Default::default(), - transform: Default::default(), - global_transform: Default::default(), - visibility: Default::default(), - computed_visibility: Default::default(), - z_index: Default::default(), - } - } -} - /// A UI node that is a button -#[derive(Bundle, Clone, Debug, Default)] +#[derive(Bundle, Clone, Debug)] pub struct ButtonBundle { /// Describes the size of the node pub node: Node, @@ -213,3 +196,22 @@ pub struct ButtonBundle { /// Indicates the depth at which the node should appear in the UI pub z_index: ZIndex, } + +impl Default for ButtonBundle { + fn default() -> Self { + Self { + focus_policy: FocusPolicy::Block, + node: Default::default(), + button: Default::default(), + style: Default::default(), + interaction: Default::default(), + background_color: Default::default(), + image: Default::default(), + transform: Default::default(), + global_transform: Default::default(), + visibility: Default::default(), + computed_visibility: Default::default(), + z_index: Default::default(), + } + } +}