Skip to content

Fix AccessKit node bounds #18706

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
merged 10 commits into from
Apr 8, 2025
Merged

Conversation

ickshonpe
Copy link
Contributor

@ickshonpe ickshonpe commented Apr 3, 2025

Objective

Fixes #18685

Solution

  • Don't apply the camera translation.
  • Calculate the min and max bounds of the accessibility node rect taking the UI translation relative to its center not the top-left corner.

Testing

Install NVDA. In NVDA set Preferences -> Settings -> Vision -> Enable Highlighting.

Then run bevy's tab_navigation example:

cargo run --example tab_navigation

If everything is working correctly, NVDA should draw a border around the currently selected tab button:

Screenshot 2025-04-07 130523

…y module.

The camera translation shouldn't be applied to UI items and UI node's translation's point to the center of the ui node not the top left corner.
@ickshonpe ickshonpe added C-Bug An unexpected or incorrect behavior 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 3, 2025
@DataTriny
Copy link
Contributor

DataTriny commented Apr 3, 2025

Testing with the tab_navigation on Windows with NVDA and exploring the UI with the mouse. I notice that my screen reader reads the role of the widgets ("Button" in this case) just before the hovering effect starts when entering the bounding box from the top and the left. It doesn't happen from the right or the bottom. Is it possible that the top-left corner of the accessible bounds fall outside of the real bounds by 1-2 pixels?

@ickshonpe
Copy link
Contributor Author

ickshonpe commented Apr 3, 2025

Testing with the tab_navigation on Windows with NVDA and exploring the UI with the mouse. I notice that my screen reader reads the role of the widgets ("Button" in this case) just before the hovering effect starts when entering the bounding box from the top and the left. It doesn't happen from the right or the bottom. Is it possible that the accessible bounds have a tiny offset of 1-2 pixels to the top-left?

If it's only a tiny margin it might be a rounding problem. I'll try flooring all the coordinate values.

@DataTriny
Copy link
Contributor

Nope, doesn't change anything. I'm not sure but this might actually be an issue with the button hovering mechanism itself. I'm visually impaired so I can't definitely say, but you might be able to observe that the borders and the "Hover" text are triggered when the mouse has already entered the hit box of the buttons when coming from the left or the top.

So the accessible bounds seem OK to me.

@DataTriny
Copy link
Contributor

Yes that's it. Using my screen magnifier I can say that there is a gap of two pixels between the top-left corner of the buttons and the area that triggers the text change and the border highlight.

Thank you very much for the quick fix!

Copy link
Contributor

@DataTriny DataTriny left a comment

Choose a reason for hiding this comment

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

Not sure whether the coordinates need to be floored then.

@alice-i-cecile alice-i-cecile added this to the 0.16 milestone Apr 3, 2025
@ickshonpe
Copy link
Contributor Author

Not sure whether the coordinates need to be floored then.

Yeah it's better not to if it didn't help.

@ickshonpe
Copy link
Contributor Author

ickshonpe commented Apr 3, 2025

I suspect the bounds are correct now and the hovering issue is caused somewhere else. If this gets another positive review we should merge and create a new issue about the 2-pixel gap I think, as it's much less critical.

@viridia
Copy link
Contributor

viridia commented Apr 5, 2025

I just patched this in to my test app, and things look better but still incorrect - looks like the coords are scaled wrong (as you anticipated). Running on a MacBook pro, the focus ring appears to be scaled by 50%, both in position and size.

@alice-i-cecile alice-i-cecile removed this from the 0.16 milestone Apr 6, 2025
@alice-i-cecile alice-i-cecile added S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Apr 6, 2025
@ickshonpe
Copy link
Contributor Author

ickshonpe commented Apr 7, 2025

I installed NVDA and tried the built in screen reader on windows but haven't been to get it to work with Bevy, not sure what I'm doing wrong.

There are some other critical bugs I noticed too. The accessibility systems only update on changes to the widget marker components, so they won't respond to changes to the state of the widgets.

@ickshonpe
Copy link
Contributor Author

Just needed to set InputFocus on the button. Works correctly now.

@ickshonpe ickshonpe added S-Needs-Review Needs reviewer attention (from anyone!) to move forward and removed S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged labels Apr 7, 2025
@ickshonpe ickshonpe added this to the 0.16 milestone Apr 7, 2025
Copy link
Contributor

@viridia viridia left a comment

Choose a reason for hiding this comment

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

Verified.

@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 and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Apr 7, 2025
@cart cart added this pull request to the merge queue Apr 8, 2025
Merged via the queue into bevyengine:main with commit fb159f9 Apr 8, 2025
32 checks passed
mockersf pushed a commit that referenced this pull request Apr 8, 2025
# Objective

Fixes #18685

## Solution

* Don't apply the camera translation.
* Calculate the min and max bounds of the accessibility node rect taking
the UI translation relative to its center not the top-left corner.

## Testing

Install [NVDA](https://www.nvaccess.org/). In NVDA set `Preferences ->
Settings -> Vision -> Enable Highlighting`.

Then run bevy's `tab_navigation` example:
```
cargo run --example tab_navigation
```
If everything is working correctly, NVDA should draw a border around the
currently selected tab button:

![Screenshot 2025-04-07
130523](https://github.com/user-attachments/assets/07d9a795-5d55-4b61-9602-2e8917020245)
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-Bug An unexpected or incorrect behavior 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.

AccessKit node bounds are wrong
5 participants