I need some clarification on the relationship between Focus
and Selection
in javafx.scene.control.TreeTableView
.
In my code I have defined:
ttvMainTree.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
Assumption 1: I was assuming, that the focused item is always the last item with left-click. Also I was assuming that the a left-click always moves the selection. So that in SelectionMode.SINGLE
the focused item and the selected item are always identical.
This seemed to be correct in 90% of all situations. Anyhow after some random left-clickes my code produced such a picture:
Kindly confirm:
Here the focused item can be changed with left-click, the selected item seems to be not influenced by left-click.
My apologies for not providing an SSCCE. At the moment I don't know how to shorten my code and reproduce this behavior.
Therefore a general question:
In my humble opinion, i don't think there is a difference on the behavior of the two, it is rather a relationship as you said, when you select a Node
, this one request the focus.
The focus can be controlled with the "focusTraversable
" :
focusTraversable : Specifies whether this Node should be a part of focus traversal cycle. When this property is true focus can be moved to this Node and from this Node using regular focus traversal keys.
For your case I think maybe it's because you have chosen a TreeTableView
that is both child and parent Child 2
!