Focus behavior on cell based controls

Michael Strauß michaelstrau2 at gmail.com
Fri Nov 22 10:49:36 UTC 2024


This was an unfortunate decision. The reason for this seems to be that
cell-based controls use the `focused` property in a non-standard way,
to remember the focused cell even when the input focus was moved to a
different control. There's no reason to do that, and can be fixed by
introducing a cell-specific property for this purpose (maybe
"retainedFocus", "cellFocus", or something like that). Controls should
never tamper with focus properties, as these are managed by the Node
class. We should probably deprecate the `Node.setFocused` method that
currently allows derived classes to change the focused property.


On Fri, Nov 22, 2024 at 11:20 AM Abhinay Agarwal
<abhinay_agarwal at live.com> wrote:
>
> Hi,
>
> Controls like ListView, TreeView, etc. always have one of the cells with focused property set to true.
>
> This causes the focusWithin property [1] (introduced in 19) on these controls to be set to true even when the actual focus is neither on them nor its children.
>
> I wonder if there is a reason for setting the focused property on one the cells always to true?
>
> - Abhinay
>
> [1] https://openjfx.io/javadoc/23/javafx.graphics/javafx/scene/Node.html#focusWithinProperty


More information about the openjfx-dev mailing list