RFR: 8090456: Focus Management [v8]

Michael Strauß mstrauss at openjdk.org
Wed Oct 9 21:46:22 UTC 2024


On Wed, 2 Oct 2024 17:33:15 GMT, Andy Goryachev <angorya at openjdk.org> wrote:

>> Public APIs for focus traversal and the focus traversal policy:
>> 
>> https://github.com/andy-goryachev-oracle/Test/blob/main/doc/FocusTraversal/FocusTraversal.md
>> 
>> This work is loosely based on the patch
>> https://cr.openjdk.org/~jgiles/8061673/
>
> Andy Goryachev has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 14 commits:
> 
>  - Merge remote-tracking branch 'origin/master' into 8090456.focus.traversal
>  - removed traversal event
>  - javadoc
>  - remove bounds
>  - whitespace
>  - Merge remote-tracking branch 'origin/master' into 8090456.focus.traversal
>  - Merge remote-tracking branch 'origin/master' into 8090456.focus.traversal
>  - review comments
>  - Merge remote-tracking branch 'origin/master' into 8090456.focus.traversal
>  - review comments part 1
>  - ... and 4 more: https://git.openjdk.org/jfx/compare/4d3c3661...9e1fa796

I would be in favor of sending this proposal back to the drawing board for the following reasons:

1. It feels like an undercooked implementation detail was promoted to API. What developers need is a way to easily customize the focus traversal behavior, instead of coding new behaviors from scratch. The correct way to do this is to realize that there are two distinct modes of focus traversal (directional and logical), and that these two modes should be separately configurable.
2. Instead of providing two separate toggles with a set of values to choose from, this API encourages developers to write custom traversal policies like the one in `ToolBarSkin`, which contains 100 lines of code that do... something, and if you just remove all of it, the behavior is almost unchanged. That's not a good "code to observable effects" ratio. It will also lead to a proliferation of poorly-made custom policies (who has the time to cover all edge cases).
3. It fails to provide an easy out-of-the-box solution for the most common developer requests, like container-cyclic focus traversal.

My suggestion for a better API is: have two separate knobs to configure directional and logical focus traversal, and provide a very small set of curated policies. We should only consider opening up the API to allow more customization when there is a demonstrable need that goes beyond the curated policies.

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

PR Comment: https://git.openjdk.org/jfx/pull/1555#issuecomment-2403483930


More information about the openjfx-dev mailing list