RFR: 8343956: Focus delegation API
Martin Fox
mfox at openjdk.org
Wed Jul 9 17:23:48 UTC 2025
On Sat, 9 Nov 2024 01:28:53 GMT, Michael Strauß <mstrauss at openjdk.org> wrote:
> Implementation of [focus delegation](https://gist.github.com/mstr2/44d94f0bd5b5c030e26a47103063aa29).
modules/javafx.graphics/src/main/java/javafx/scene/Node.java line 8654:
> 8652: * @since 26
> 8653: */
> 8654: Node getFocusDelegate(Node hoistingNode) {
I tried to tweak the InputMethodStateManager to deal with delegates and discovered there’s no easy way to get a node’s delegate. Shouldn’t there be a public way of retrieving the current delegate?
I don’t think getFocusDelegate should take a parameter. If I was creating a node with multiple focus delegates I would probably want to track the current one in some simple way. But getFocusDelegate doesn’t allow me to do that, I always have to respect the hoisting node parameter being passed in and dig through my descendant nodes to figure out which delegate is being requested. And it implies the only way to change the delegate is to requestFocus on the new delegate and take it through the hoisting process. That seems overly restrictive. I can see why a focus scope node would need to know which node hoisted focus but only at the time the hoist happens.
We’re spending a lot of time thinking about controls that may have more than one delegate. I really doubt anyone will ever create one. If they do it raises a bunch of questions related to accessibility and keyboard traversal that we’re not even discussing.
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/1632#discussion_r2195566726
More information about the openjfx-dev
mailing list