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

[Merged by Bors] - Add FocusPolicy to NodeBundle and ImageBundle #3952

Closed
wants to merge 1 commit into from

Conversation

Sliman4
Copy link
Contributor

@Sliman4 Sliman4 commented Feb 14, 2022

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:

Option<&FocusPolicy>,
and then it treats it as Block if it's not present:
match focus_policy.cloned().unwrap_or(FocusPolicy::Block) {
and the default value is
impl Default for FocusPolicy {
fn default() -> Self {
FocusPolicy::Block
}
}
so it should be compatible with all existing UIs that use ..Default::default()

@github-actions github-actions bot added the S-Needs-Triage This issue needs to be labelled label Feb 14, 2022
@alice-i-cecile alice-i-cecile added A-UI Graphical user interfaces, styles, layouts, and widgets C-Feature A new feature, making something new possible and removed S-Needs-Triage This issue needs to be labelled labels Feb 14, 2022
@alice-i-cecile
Copy link
Member

Cool! This is absolutely useful, and your reasoning is great. Thanks for the first contribution :)

@cart
Copy link
Member

cart commented Feb 15, 2022

I'm on board for this change. We should definitely try to include relevant components in bundles whenever possible, to improve discoverability.

@cart
Copy link
Member

cart commented Feb 15, 2022

(and future editor scenarios)

@cart
Copy link
Member

cart commented Feb 15, 2022

bors r+

bors bot pushed a commit that referenced this pull request Feb 15, 2022
# 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()`
@bors bors bot changed the title Add FocusPolicy to NodeBundle and ImageBundle [Merged by Bors] - Add FocusPolicy to NodeBundle and ImageBundle Feb 15, 2022
@bors bors bot closed this 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-Feature A new feature, making something new possible
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Click to child NodeBundle does not emit parent ButtonBundle interaction
3 participants