Implement accessibility for ListBox#20733
Open
kirb wants to merge 11 commits intoAvaloniaUI:masterfrom
Open
Conversation
The mapping proposed in the doc comments is modified because there is no direct concept of multiple selection in VoiceOver. `Select()` maps to both `-accessibilityPerformPick` and `-setAccessibilitySelected:YES`, with `RemoveFromSelection()` mapped to `-setAccessibilitySelected:NO`. This feels like it better maps to what the API intends.
This creates an automation peer for ListBox that returns actual or virtual automation peers for the items in the list. This allows VoiceOver to be aware of the number of items, and be able to navigate between them, even if not visible in the current viewport. Fixes AvaloniaUI#20685.
These serve similar behaviors, and the unrealized/virtual element peer can subclass from UnrealizedElementAutomationPeer.
This ensures the screen reader follows the item when it transitions from unrealised to realised. Otherwise, navigation may be random.
Exposing -accessibilitySelectedChildren allows VoiceOver to enter a multiple selection mode. This is triggered the first time the user presses VO-Cmd-Return. In this mode, it stops calling -setAccessibilitySelected: with a parameter of YES each time the user lands on an item. Instead, it toggles the selection when the user presses VO-Cmd-Return.
|
You can test this PR using the following package version. |
Contributor
|
This creates a regression in Windows, where list items are no longer announced after scrolling. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does the pull request do?
Implements missing accessibility support in ListBox by adding an automation peer (see below for why). Also implements
ISelectionItemProvideron macOS.What is the current behavior?
What is the updated/expected behavior with this PR?
How was the solution implemented (if it's not obvious)?
ListBoxAutomationPeerhas been added. This subclassesSelectingItemsControlAutomationPeerso selection events are correctly raised. It overrides to return a custom list of children, where any that are not in viewport are of typeUnrealizedListItemAutomationPeer. This provides just enough info to stand in for theListItem’s actual automation peer. The screen reader now knows exactly how many items are in the list, and can navigate through all of them, including non-sequentially via features such as Find. For the latter,GetNameCore()evaluates theDisplayMemberBindingto get a placeholder name.The remainder of
ISelectionItemProviderhas been implemented on macOS, although the relevant NSAccessibility methods end up working differently from how they seem to have been originally thought out. “Pick” is invoked by VO-Space, and callsSelect(). List items become selected ([view setAccessibilitySelected:YES]is called) as soon as the user lands on it. However, by pressing VO-Cmd-Return, the list enters a mode where it stops immediately selecting items. It then will toggle selection by pressing VO-Cmd-Return again.Checklist
Breaking changes
None
Obsoletions / Deprecations
None
Fixed issues
Fixes #20685.
I haven’t yet tested this on Windows. Will update when I have a chance to do so.
I also can’t get the control catalog ListBox demo to correctly speak row indexes - it says “1 of 10,000” for all rows. I tried adding an implementation of
accessibilityIndex, but it seems to not get used, so I didn’t include it in this PR. In future, it would make sense to implement theNSAccessibilityTable/NSAccessibilityRowprotocols (andNSAccessibilityList, which is identical toNSAccessibilityTable). Lists seem to work informally, with the system figuring out item index and count itself based on the children array, while tables require formal implementation of every method in those protocols. There may be a case for switching back toNSAccessibilityTableRoleonce this is implemented - it would matchNSTableView/NSCollectionViewas used by native apps, including sidebars in Finder and System Settings.