RFR: 8271846 a11y API lacks setSelectedIndex method [v2]

Artem Semenov asemenov at openjdk.org
Wed Nov 9 09:04:19 UTC 2022


On Wed, 9 Nov 2022 04:29:57 GMT, Phil Race <prr at openjdk.org> wrote:

>> I am still waiting for the following questions (from July) to be answered here (not somewhere else)
>> 
>>> You did not acknowledge this is not a backportable fix
>> 
>> By which I mean, if this needs to be solved in say JDK 11 too, what will you do ??
>> 
>>> I'd like you to explain why calling setSelectedIndex isn't good enough AND why Windows A11Y does not need this API
>> 
>> Also leaving aside that you haven't yet shown the API is needed I note that there are javax.accessibility is NOT
>> the place for Component specific A11Y classes.
>> So adding javax.accessibility.AccessibleList looks like a very anomalous and perhaps incorrect design.
>> 
>> The similar examples are nested classes of the component, eg
>> JTree.AccessibleJTree
>> JTable.AccessibleJTable
>> 
>> In fact there's even already a JList.AccessibleJList !
>> 
>> And it seems to have things that look similar to things you say you need
>> https://docs.oracle.com/en/java/javase/17/docs/api/java.desktop/javax/swing/JList.AccessibleJList.html#isAccessibleChildSelected(int)
>> 
>> and your API
>> 
>> +    boolean isSelectedIndex(int index);
>> 
>> ===
>> 
>> and
>> public int getAccessibleSelectionCount()
>> Returns the number of items currently selected. If no items are selected, the return value will be 0.
>> 
>> ===
>> and you have
>> 
>> +    /**
>> +     * Returns true if no indices are selected.
>> +     *
>> +     * @return {@code true} if no indices are selected.
>> +     */
>> +    boolean isSelectionEmpty();
>> 
>> etc etc ..
>
>> @prrace I acknowledge that this change is not portable.
>> 
>> The absence of the dedicated AccessibleList interface does not allow setting selections on lists on MacOS using the accessible shortcuts and external accessibility devices. The current solution severely limits the ability of accessibility subsystem to interact with the list component thus it is not acceptable. Existing implementation uses AccessibleSelection implemented in the JList but it lacks ability to work with multiple selection intervals and side effects of setting singular selection with sequential calling of clearSelection() and addSelection() lead to the the line selection action being repeated by the VoiceOver indefinitely.
>> 
>> We need a new accessibility interface that will implement the selection model for accessibility lists. Also it should provide additional information about the list, regardless of whether the accessibility list is inherited from JList or impolemented from scratch. New interface should be able to provide system with the additional information such as selection mode and should be flexible enough to allow implementation of both single and multiselection modes. The AccessibleSelection interface does not allow working with index intervals, which will prevent the implementation of multiple selection in the future. This interface is not yet relevant on windows because the most common readers do not have a screen navigation modes similar to VoiceOver quick navigation and the current functionality is sufficient.
> 
> You didn't speak to the duplicated functionality.
> We should retrofit / add to the existing nested class, if new API is truly needed. 
> "Nothing here is "inherited from JList". AccessibleJList is a nested class, not an inheritance relationship.
> API mistakes are hard to un-do so it is not possible for me to sign off on this without somehow finding
> enough time to study this API and come to my own conclusions since what I see now looks so anomalous.
> Perhaps if you can find someone who knows the A11Y APIs it would go faster, but that isn't me.

@prrace in file ```src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessibility.java:569```
There is a direct inheritance dependence on JList. And that is exactly what needs to be avoided. It was pointed out to me [here](https://github.com/openjdk/jdk/pull/4412/files#r653062357 "github.com"). Without changes, a non-JList-based list will not work.

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

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



More information about the client-libs-dev mailing list