Skip to content

Commit d3e526b

Browse files
committed
Add FocusPolicy to NodeBundle and ImageBundle (#3952)
# Objective `FocusPolicy` allows tracking `Interaction` of a parent node when a player hovers/clicks at the child node, and I see no reason why it shouldn't exist in these 2 nodes. Resolves #2488 ## Solution Add it! In the tracking system it's used as `Option`: https://github.com/bevyengine/bevy/blob/e749ee786c3a3ca11718b08f0545aa90e4b5aae6/crates/bevy_ui/src/focus.rs#L71 and then it treats it as `Block` if it's not present: https://github.com/bevyengine/bevy/blob/e749ee786c3a3ca11718b08f0545aa90e4b5aae6/crates/bevy_ui/src/focus.rs#L162 and the default value is https://github.com/bevyengine/bevy/blob/e749ee786c3a3ca11718b08f0545aa90e4b5aae6/crates/bevy_ui/src/focus.rs#L47-L51 so it should be compatible with all existing UIs that use `..Default::default()`
1 parent 5104397 commit d3e526b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

crates/bevy_ui/src/entity.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ pub struct NodeBundle {
2323
pub color: UiColor,
2424
/// Describes the image of the node
2525
pub image: UiImage,
26+
/// Whether this node should block interaction with lower nodes
27+
pub focus_policy: FocusPolicy,
2628
/// The transform of the node
2729
pub transform: Transform,
2830
/// The global transform of the node
@@ -46,6 +48,8 @@ pub struct ImageBundle {
4648
pub color: UiColor,
4749
/// The image of the node
4850
pub image: UiImage,
51+
/// Whether this node should block interaction with lower nodes
52+
pub focus_policy: FocusPolicy,
4953
/// The transform of the node
5054
pub transform: Transform,
5155
/// The global transform of the node

0 commit comments

Comments
 (0)