-
Notifications
You must be signed in to change notification settings - Fork 79
UI Accessibility: expose painted (non-QWidget) items as accessible children via Accessible::Item #278
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
base: master
Are you sure you want to change the base?
Conversation
- Introduce Ui::Accessible::Item and AccessibleItemWrap to expose non-QWidget / non-QObject items via QAccessibleInterface - Switch Ui::Accessible::Widget custom child handling to RpWidget::accessibilityChildInterface(index) - Implement hit-testing via Widget::childAt(x, y) for custom accessibility children - Improve focusChild() by returning the custom child whose state is focused or selected - Add RpWidget hooks for child metadata (accessibilityChildName/Description/Value) - Remove legacy RpWidget child APIs (accessibilityChildAt / accessibilityIndexOfChild / accessibilityFocusChild) - Update CMakeLists.txt to compile the new accessible item sources
abf672e to
2d0f6ad
Compare
|
|
||
| const auto index = _item->accessibilityIndex(); | ||
| if (index < 0) return false; | ||
| if (const auto rp = qobject_cast<Ui::RpWidget*>(widget)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if (const auto rp = qobject_cast<Ui::RpWidget*>(widget)) { | |
| if (const auto rp = dynamic_cast<Ui::RpWidget*>(widget)) { |
| if (!_item) return QString(); | ||
|
|
||
| const auto widget = _item->accessibilityParentWidget(); | ||
| const auto rp = widget ? qobject_cast<Ui::RpWidget*>(widget) : nullptr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| const auto rp = widget ? qobject_cast<Ui::RpWidget*>(widget) : nullptr; | |
| const auto rp = dynamic_cast<Ui::RpWidget*>(widget); |
| virtual QAccessibleInterface* accessibilityChildInterface(int index) const { | ||
| return nullptr; | ||
| } | ||
| virtual QString accessibilityChildName(int index) const { return QString(); } | ||
| virtual QString accessibilityChildDescription(int index) const { return QString(); } | ||
| virtual QString accessibilityChildValue(int index) const { return QString(); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why those are declared in .h unlike others?
This PR adds accessibility support for painted UI elements that are not real QWidgets (i.e., items drawn inside a widget). The goal is to make these “virtual” elements appear in the accessibility tree so screen readers can discover, navigate, and interact with them.
Summary
•
Introduces Ui::Accessible::Item (QAccessibleInterface) plus AccessibleItemWrap to represent non-QWidget / non-QObject painted items as accessibility nodes.
•
Extends RpWidget with a simple API to expose painted items as accessibility children via accessibilityChildInterface(index), along with optional text hooks:
•
accessibilityChildName(int)
•
accessibilityChildDescription(int)
•
accessibilityChildValue(int)
•
Updates Ui::Accessible::Widget to use the new interface-based child API and support:
•
correct child lookup (child(index))
•
hit-testing for painted items (childAt(x, y))
•
improved focus reporting (focusChild() returns the focused/selected painted item when the widget has focus)
•
Removes the old widget-only child accessibility methods on RpWidget (accessibilityChildAt, accessibilityIndexOfChild, accessibilityFocusChild) since they don’t fit painted-item scenarios.
Why
A lot of our UI is rendered manually (custom painting) rather than composed from actual Qt widgets. Without explicit QAccessibleInterface objects, those elements are invisible to assistive technologies. This change provides a clean path to expose painted items with proper role, state, geometry, and text, without requiring them to be real widgets.
Notes
•
Item geometry is mapped to global coordinates for accurate screen reader hit-testing.
•
Validation ensures the parent widget exists and indices are within bounds when a child count is provided.
Testing
•
Manual verification with a screen reader:
•
painted items are discoverable in the accessibility tree
•
hit-testing works (childAt returns the correct item)
•
focus/selection is reflected correctly for painted items