-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
UI button is still Interaction::Pressed
when to the right of its Overflow::clip()
parent.
#10668
Comments
Does #10454 fix this issue for you? |
It does fix the "clicking in the right area outside of the root node" part, which is the most annoying and wrong one, and the reason I wrote this issue. It doesn't fix the weird interactions with the borders though, so I will probably keep this open for that reason. Thank you for linking it! |
Interaction::Pressed
when to the right of it's Overflow::clip()
parent.Interaction::Pressed
when to the right of its Overflow::clip()
parent.
The interactions with the borders are correct. Instead, you need to change the border so it's around and not inside the node with clipping. I modified your example to what I think is the desired behaviour: use bevy::prelude::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_systems(Startup, setup)
.add_systems(Update, interact_check)
.run();
}
fn setup(mut commands: Commands) {
commands.spawn(Camera2dBundle::default());
commands.spawn(NodeBundle {
style: Style {
position_type: PositionType::Absolute,
left: Val::Px(300.),
top: Val::Px(300.),
border: UiRect::all(Val::Px(10.)),
..Default::default()
},
border_color: BorderColor(Color::PURPLE),
..Default::default()
}).with_children(|parent| {
parent.spawn(NodeBundle {
style: Style {
width: Val::Px(200.),
height: Val::Px(200.),
overflow: Overflow::clip(),
..default()
},
..default()
}).with_children(|parent| {
parent.spawn(NodeBundle {
style: Style {
position_type: PositionType::Absolute,
width: Val::Px(600.),
height: Val::Px(200.),
left: Val::Px(-200.),
..default()
},
..default()
}).with_children(|parent| {
parent.spawn(ButtonBundle {
style: Style {
width: Val::Px(200.),
height: Val::Px(200.),
..default()
},
background_color: BackgroundColor(Color::RED),
..default()
});
parent.spawn(ButtonBundle {
style: Style {
width: Val::Px(200.),
height: Val::Px(200.),
..default()
},
background_color: BackgroundColor(Color::GREEN),
..default()
});
parent.spawn(ButtonBundle {
style: Style {
width: Val::Px(200.),
height: Val::Px(200.),
..default()
},
background_color: BackgroundColor(Color::BLUE),
..default()
});
});
});
});
}
fn interact_check(
interactions: Query<(&Interaction, &BackgroundColor), Changed<Interaction>>
) {
for (interaction, background_color) in interactions.iter() {
if matches!(interaction, Interaction::Pressed) {
dbg!(format!("Pressed {:?}", background_color.0));
}
}
} |
@ickshonpe I see, I didn't know that was expected behavior. I will close this as a non-issue/duplicate of #10470 then. |
Bevy version
0.12.0
What you did
Try to make a Carroussel, here is a simplified version with a root node (with purple border) that hides the overflow, a stip node just underneath, and three item children (red, blue and green background) that can be clicked. The strip is setup to display the middle child, green.
What went wrong
Interaction
component of the first red item doesn't change toPressed
, this is expectedInteraction
of the third blue item changes toPressed
, I feel like it shouldn'tInteraction
component changes toPressed
, I feel like it shouldn't.The text was updated successfully, but these errors were encountered: