Reputation: 289
I have a lot of TextArea
nodes in a Scene
.
Is it possible for me to figure out which TextArea
is selected (has the caret in it)?
I would like to be able to select the node and set it to a Node
variable.
Upvotes: 11
Views: 8534
Reputation: 6952
Actually there is no need to set a focused node variable, because Scene
already contains a focusOwnerProperty
.
So you could use it e.g. like:
if (scene.focusOwnerProperty().get() instanceof TextArea) {
TextArea focusedTextArea = (TextArea) scene.focusOwnerProperty().get();
}
Upvotes: 23