RFR: 8271846 a11y API lacks setSelectedIndex method [v4]

Artem Semenov asemenov at openjdk.org
Mon Nov 28 09:26:13 UTC 2022


On Wed, 9 Nov 2022 09:42:00 GMT, Artem Semenov <asemenov at openjdk.org> wrote:

>> A11Y implementation on macOS has to directly call the 'JList.setSelectedIndex' method in order to request selection on an item (see 'CAccessibility.requestSelection'). The reason is that a11y API lacks appropriate method.There's only 'javax.accessibility.AccessibleSelection#addAccessibleSelection' which is mapped to 'javax.swing.JList#addSelectionInterval', it can not be used to set selected index.
>> 
>> @forantar @azuev-java @mrserb please review.
>> 
>> Please note that the new API allows you to implement a multiple selection in lists from the Java side, but I did not succeed in implementing it, because I could not determine the inclusion of the so-called "VoiceOver multiple selection mode".
>
> Artem Semenov has updated the pull request incrementally with one additional commit since the last revision:
> 
>   We are not using author tags in tests either - but that's just a nitpick.

@mrserb
Some probably related points, the implementation of the addAccessibleSelection for the JComboBox. is the same:

            clearAccessibleSelection();
            JComboBox.this.setSelectedIndex(i);

It is possible that it also hangs?

I'm not sure if this should affect comboboxes. The combo box is arranged differently. When the ComboBox is opened, the focus is moved not to the list, but to the root panel, and from it it is proxied to the list items, which are a set of buttons that are not hierarchically or in any way connected.

---

Are you sure that the selection should be always cleared in this method, how it will work if the jlist supports multiline selection? Or voice over does not support multyline selection?
As a fix, you can delete listeners from the jlist so your request to clear the current selection will not be sent back to the voiceover. Or you can add a new method to the AccessibleSelection interface with the default implementation "clearAccessibleSelection+addAccessibleSelection". Then override it in the jlist to call setSelectedIndex().

As stated in the pull request description. We cannot yet implement multiple selection with VO quick navigation, as this part of the A11y API is not described by Apple.
Calling ClearSelection will really prevent you from implementing multiple selection in the future, so we propose a new interface that will allow you to implement multiple selection in the future. Because it gives access not only to different methods of setting the selection, but also to the selection mode.
The proposed solution with removing the listener will not solve the problem of binding this piece of code to the JList that we are solving.

-------------

PR: https://git.openjdk.org/jdk/pull/8578



More information about the client-libs-dev mailing list