Skip to content

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

Closed
@swwind

Description

@swwind

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!!!
😱😱😱

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-UIGraphical user interfaces, styles, layouts, and widgetsC-DocsAn addition or correction to our documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions