Focused nodes and focus owners
Michael Strauß
michaelstrau2 at gmail.com
Fri Aug 18 16:35:17 UTC 2023
Scene graph nodes have three focus-related properties:
1. focused
2. focus-within
3. focus-visible
What might be a bit surprising is that multiple nodes can be focused
at the same time, but only one of those focused nodes can be the
scene's focus owner. The `Scene.focusOwner` property indicates which
of the focused nodes is the current focus owner.
Even more surprisingly, a node can be _unfocused_ and be the focus
owner at the same time (this can happen when the window is
deactivated).
>From the perspective of `Node`, there's currently no API to easily
determine whether it is the focus owner, and there's no CSS
pseudo-class that matches a node that is the focus owner.
We could add two more properties to the `Node` class to support this use case:
4. focus-owner
5. focus-owner-within
Note that `focus-visible` only matches nodes that are also focus
owners, so there's no need to have a `focus-owner-visible` property.
The two additional properties would suffice to match any possible
focus state, but it might also be not useful enough to warrant the
additional API surface. What do you think?
More information about the openjfx-dev
mailing list