Skip to content

Add a component to enable/disable interactions on a UI node #16270

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Exanc
Copy link

@Exanc Exanc commented Nov 6, 2024

Objective

Project goal: Component type for enabling/disabling UI widget interactions (allow inactive buttons, etc…)

Solution

The Interactivity component.
It stores a state describing whether an Interactive Node can be interacted with or not.

An interactive node can be described as an entity containing both the Node and Interaction components.

The Interactivity component can be defined with the following properties:

#[derive(Component, ...)]
#[require(Node, Interaction)]
pub enum Interactivity {
	Enabled,
	Disabled,
}

It is used by the ui_focus_system to determine whether an interactive node should have it's Interaction component updated when an interaction does occur. Furthermore, the assertion should be made that a "disabled" entity will always have it's Interaction component set to Interaction::None.

It can also be used by secondary systems to, for example, change the visual appearance of a UI node, or to decide whether or not to use FocusPolicy::Block.

Testing

Not yet

Migration Guide

Migrations are not necessary as the absence of the Interactivity component is interpreted as the component being enabled.

@Exanc
Copy link
Author

Exanc commented Nov 6, 2024

There is still a missing, point: when an Interactivity component is changed, where should it be detected ? ui_focus_system or another on ?
Should we instantly change the interaction to None or let the current one finish ?

@alice-i-cecile alice-i-cecile added C-Feature A new feature, making something new possible A-UI Graphical user interfaces, styles, layouts, and widgets M-Needs-Release-Note Work that should be called out in the blog due to impact S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged labels Nov 6, 2024
@alice-i-cecile
Copy link
Member

alice-i-cecile commented Nov 6, 2024

#15597 will be removing ui_focus_system and Interaction. I would integrate with bevy_picking and try and use observers where possible.

@Exanc
Copy link
Author

Exanc commented Nov 7, 2024

@alice-i-cecile did not notice this change, there's a lot of info to keep up with 😅

@Exanc
Copy link
Author

Exanc commented Nov 7, 2024

Should we instantly change the interaction to None or let the current one finish ?

The interaction states of components will instantly be changed, to keep up with the assertions made.

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 M-Needs-Release-Note Work that should be called out in the blog due to impact S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants