RFR: 8091673: Public focus traversal API for use in custom controls [v3]

Michael Strauß mstrauss at openjdk.org
Mon Oct 28 06:14:07 UTC 2024


On Fri, 25 Oct 2024 16:22:01 GMT, Andy Goryachev <angorya at openjdk.org> wrote:

>> Public focus traversal API for use in custom controls
>> 
>> https://github.com/andy-goryachev-oracle/Test/blob/main/doc/FocusTraversal/FocusTraversal-v3.md
>> 
>> This work is loosely based on the patch
>> https://cr.openjdk.org/~jgiles/8061673/
>> 
>> And is a scaled down version (with the public traversal policy API removed) of
>> #1555
>
> Andy Goryachev has updated the pull request incrementally with one additional commit since the last revision:
> 
>   review comments

modules/javafx.graphics/src/main/java/javafx/scene/Node.java line 10443:

> 10441:     /**
> 10442:      * Requests focus traversal from this {@code Node} in the specified direction.
> 10443:      * A successful traversal results in the newly focused {@code Node} visibly indicating its focused state.

What's the rationale behind always setting the `focusVisible` bit when doing programmatic focus traversal? Visible focus is always cleared when calling the existing `requestFocus()` method, since it is specified to _only_ be set when focus is acquired by keyboard navigation.

Maybe we should have the next node visibly indicate focus if (and only if) the current node visibly indicates focus. This would be consistent with the [Selectors 4 spec](https://www.w3.org/TR/selectors-4/#the-focus-visible-pseudo):
> If the previously-focused element indicated focus, and a script causes focus to move elsewhere, the newly focused element should indicate focus.

> 
> Conversely, if the previously-focused element did not indicate focus, and a script causes focus to move elsewhere, the newly focused element should also not indicate focus.

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

PR Review Comment: https://git.openjdk.org/jfx/pull/1604#discussion_r1818426076


More information about the openjfx-dev mailing list