Fix: Filter for BigRedButton in it's observers
There was no BRB component so the Observer systems would only filter for `Button`, which matched against the close button by accident.
This commit is contained in:
@@ -95,6 +95,7 @@ impl BigRedButton {
|
|||||||
fn spawn_big_red_button(commands: &mut ChildSpawnerCommands, text: impl Into<String>) {
|
fn spawn_big_red_button(commands: &mut ChildSpawnerCommands, text: impl Into<String>) {
|
||||||
let mut builder = commands.spawn((
|
let mut builder = commands.spawn((
|
||||||
Button,
|
Button,
|
||||||
|
BigRedButton,
|
||||||
Node {
|
Node {
|
||||||
width: Px(60.0),
|
width: Px(60.0),
|
||||||
height: Px(60.0),
|
height: Px(60.0),
|
||||||
@@ -124,7 +125,7 @@ impl BigRedButton {
|
|||||||
event: Trigger<Pointer<Over>>,
|
event: Trigger<Pointer<Over>>,
|
||||||
// Get button background and border colors so we can change them.
|
// Get button background and border colors so we can change them.
|
||||||
// Filter for *changed* interactions, and only entities with a [`Button`]
|
// Filter for *changed* interactions, and only entities with a [`Button`]
|
||||||
mut button_colors: Query<(&mut BackgroundColor, &mut BorderColor), With<Button>>,
|
mut button_colors: Query<(&mut BackgroundColor, &mut BorderColor), With<BigRedButton>>,
|
||||||
ui_theme: Res<UiTheme>,
|
ui_theme: Res<UiTheme>,
|
||||||
) {
|
) {
|
||||||
// Get the components for only the Trigger's target entity
|
// Get the components for only the Trigger's target entity
|
||||||
@@ -139,7 +140,7 @@ impl BigRedButton {
|
|||||||
|
|
||||||
fn button_hover_stop(
|
fn button_hover_stop(
|
||||||
event: Trigger<Pointer<Out>>,
|
event: Trigger<Pointer<Out>>,
|
||||||
mut button_colors: Query<(&mut BackgroundColor, &mut BorderColor), With<Button>>,
|
mut button_colors: Query<(&mut BackgroundColor, &mut BorderColor), With<BigRedButton>>,
|
||||||
ui_theme: Res<UiTheme>,
|
ui_theme: Res<UiTheme>,
|
||||||
) {
|
) {
|
||||||
if let Ok((mut bg, mut border)) = button_colors.get_mut(event.target()) {
|
if let Ok((mut bg, mut border)) = button_colors.get_mut(event.target()) {
|
||||||
@@ -150,7 +151,7 @@ impl BigRedButton {
|
|||||||
|
|
||||||
fn button_press_start(
|
fn button_press_start(
|
||||||
event: Trigger<Pointer<Pressed>>,
|
event: Trigger<Pointer<Pressed>>,
|
||||||
mut button_colors: Query<(&mut BackgroundColor, &mut BorderColor), With<Button>>,
|
mut button_colors: Query<(&mut BackgroundColor, &mut BorderColor), With<BigRedButton>>,
|
||||||
ui_theme: Res<UiTheme>,
|
ui_theme: Res<UiTheme>,
|
||||||
) {
|
) {
|
||||||
if let Ok((mut bg, mut border)) = button_colors.get_mut(event.target()) {
|
if let Ok((mut bg, mut border)) = button_colors.get_mut(event.target()) {
|
||||||
@@ -161,7 +162,7 @@ impl BigRedButton {
|
|||||||
|
|
||||||
fn button_press_stop(
|
fn button_press_stop(
|
||||||
event: Trigger<Pointer<Released>>,
|
event: Trigger<Pointer<Released>>,
|
||||||
mut button_colors: Query<(&mut BackgroundColor, &mut BorderColor), With<Button>>,
|
mut button_colors: Query<(&mut BackgroundColor, &mut BorderColor), With<BigRedButton>>,
|
||||||
ui_theme: Res<UiTheme>,
|
ui_theme: Res<UiTheme>,
|
||||||
) {
|
) {
|
||||||
if let Ok((mut bg, mut border)) = button_colors.get_mut(event.target()) {
|
if let Ok((mut bg, mut border)) = button_colors.get_mut(event.target()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user