Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Click to child NodeBundle does not emit parent ButtonBundle interaction #2488

Closed
swwind opened this issue Jul 16, 2021 · 1 comment
Closed
Labels
A-UI Graphical user interfaces, styles, layouts, and widgets C-Docs An addition or correction to our documentation

Comments

@swwind
Copy link

swwind commented Jul 16, 2021

Bevy version

97d8e4e

Operating system & version

Arch Linux Plasma 5.22.1

What you did

use bevy::prelude::*;

fn main() {
    App::build()
        .add_plugins(DefaultPlugins)
        .add_startup_system(setup.system())
        .add_system(listen.system())
        .run();
}

fn listen(query: Query<&Interaction, (Changed<Interaction>, With<Button>)>) {
    for interaction in query.iter() {
        println!("{:?}", interaction);
    }
}

fn setup(mut commands: Commands, mut materials: ResMut<Assets<ColorMaterial>>) {
    commands.spawn_bundle(UiCameraBundle::default());
    commands
        .spawn_bundle(ButtonBundle {
            style: Style {
                size: Size::new(Val::Percent(50.0), Val::Percent(50.0)),
                ..Default::default()
            },
            material: materials.add(Color::BLUE.into()),
            ..Default::default()
        })
        .with_children(|parent| {
            parent.spawn_bundle(NodeBundle {
                style: Style {
                    size: Size::new(Val::Percent(50.0), Val::Percent(50.0)),
                    ..Default::default()
                },
                material: materials.add(Color::GREEN.into()),
                ..Default::default()
            });
        });
}

What you expected to happen

Click the child node also emits parent button interaction change.

What actually happened

Click the child node and nothing happend to the parent button.

Additional information

Their documents were all blank!!!
😱😱😱

@swwind swwind added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Jul 16, 2021
@mockersf
Copy link
Member

mockersf commented Jul 16, 2021

As is clearly not explained in the documentation, you need to add the component FocusPolicy::Pass to your NodeBundle for it to let the click event go to its parent...

@mockersf mockersf added A-UI Graphical user interfaces, styles, layouts, and widgets C-Docs An addition or correction to our documentation and removed C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Jul 16, 2021
@bors bors bot closed this as completed in d3e526b Feb 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-UI Graphical user interfaces, styles, layouts, and widgets C-Docs An addition or correction to our documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants