Skip to content

Enable accessibility features for the button example #18749

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

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

Conversation

ickshonpe
Copy link
Contributor

@ickshonpe ickshonpe commented Apr 7, 2025

Objective

Accessibility features don't work with the UI button example because InputFocus must be set for the accessibility systems to recognise the button.

Fixes #18760

Solution

  • Set the button entity as the InputFocus when it is hovered or pressed.
  • Call set_changed on the Button component when the button's state changes to hovered or pressed (the accessibility system's only update the button's state when the Button component is marked as changed).

Testing

Install NVDA, it should say "hover" when the button is hovered and "pressed" when the button is pressed.

The bounds of the accessibility node are reported incorrectly. I thought we fixed this, I'll take another look at it. It's not a problem with this PR.

@ickshonpe ickshonpe added C-Examples An addition or correction to our examples A-Accessibility A problem that prevents users with disabilities from using Bevy A-UI Graphical user interfaces, styles, layouts, and widgets S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Apr 8, 2025
Copy link
Contributor

@djeedai djeedai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we change the name of the button to avoid having it said twice? Examples are also about creating clarity.

Copy link
Contributor

@greeble-dev greeble-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have much UI or accessibility experience, but I'm clicking approve as the changes look sensible and I've tested it works with NVDA (Win 10).

ickshonpe added 2 commits May 12, 2025 12:13
… changes to hovered or pressed. The accessibility system's only update the button's state when the `Button` component is marked as changed.
@ickshonpe
Copy link
Contributor Author

ickshonpe commented May 12, 2025

Can we change the name of the button to avoid having it said twice? Examples are also about creating clarity.

Yep, now the screen reader should report "hovered" when the button is hovered and "pressed" when the button is pressed.

@ickshonpe ickshonpe added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it D-Straightforward Simple bug fixes and API improvements, docs, test and examples and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels May 12, 2025
@ickshonpe ickshonpe changed the title enable accessibility for the button example Enable accessibility features for the button example May 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Accessibility A problem that prevents users with disabilities from using Bevy A-UI Graphical user interfaces, styles, layouts, and widgets C-Examples An addition or correction to our examples D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The UI Button example should support accessibility
3 participants