Skip to content

Conversation

@rezabakhshilaktasaraei
Copy link
Contributor

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

- 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant