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

Add "bevy_input_focus" crate. #15611

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

Add "bevy_input_focus" crate. #15611

wants to merge 2 commits into from

Conversation

viridia
Copy link
Contributor

@viridia viridia commented Oct 3, 2024

Objective

Define a framework for handling keyboard focus and bubbled keyboard events, as discussed in #15374.

Solution

Introduces a new crate, bevy_input_focus. This crate provides:

  • A resource for tracking which entity has keyboard focus.
  • Methods for getting and setting keyboard focus.
  • Event definitions for triggering bubble-able keyboard input events to the focused entity.
  • A system for dispatching keyboard input events to the focused entity.

This crate does not provide any integration with UI widgets, or provide functions for
tab navigation or gamepad-based focus navigation, as those are typically application-specific.

Testing

Most of the code has been copied from a different project, one that has been well tested. However, most of what's in this module consists of type definitions, with relatively small amounts of executable code. That being said, I expect that there will be substantial bikeshedding on the design, and I would prefer to hold off writing tests until after things have settled.

I think that an example would be appropriate, however I'm waiting on a few other pending changes to Bevy before doing so. In particular, I can see a simple example with four buttons, with focus navigation between them, and which can be triggered by the keyboard.

@alice-i-cecile

@alice-i-cecile alice-i-cecile added this to the 0.16 milestone Oct 3, 2024
@alice-i-cecile alice-i-cecile added A-Input Player input via keyboard, mouse, gamepad, and more A-UI Graphical user interfaces, styles, layouts, and widgets X-Controversial There is active debate or serious implications around merging this PR A-Picking Pointing at and selecting objects of all sorts C-Feature A new feature, making something new possible C-Needs-Release-Note Work that should be called out in the blog due to impact labels Oct 3, 2024
@alice-i-cecile
Copy link
Member

I really want this, and I like the fundamental design. At the start of the 0.16 cycle I'm going to come back to this, evaluate scope and then decide how to proceed. We may want a working group for all of the follow-up.

@alice-i-cecile alice-i-cecile added the S-Needs-SME Decision or review from an SME is required label Oct 3, 2024
@viridia
Copy link
Contributor Author

viridia commented Oct 3, 2024

One thing that has not been established is the relationship between this and bevy_a11y. I had originally assumed that this would depend on bevy_a11y, but it sounds like you were thinking that it would be the other way around.

@alice-i-cecile
Copy link
Member

Yeah, my expectation is that bevy_a11y is a consumer of the focus data produced here from user input, and so should depend on this crate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Input Player input via keyboard, mouse, gamepad, and more A-Picking Pointing at and selecting objects of all sorts A-UI Graphical user interfaces, styles, layouts, and widgets C-Feature A new feature, making something new possible C-Needs-Release-Note Work that should be called out in the blog due to impact S-Needs-SME Decision or review from an SME is required X-Controversial There is active debate or serious implications around merging this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants