I have a TextField
, and I would like to do something if the user clicks anywhere that is not the TextField
itself.
- Apparently, the
onMouseClicked
event won't trigger if you don't click the node itself, so that wouldn't work. - Listening the
focusedProperty
may have been a good idea, but the problem is that almost the entirety of my application is not focus traversable, so in many cases clicking outside the textfield won't unfocus it, so the listener won't be notified.
The only thing left in my mind is to put an event filter on the scene itself, intercept mouse clicks, get the click coordinates and determine if they fall within the bounds of the textfield. I find this a little bit overkill and I may be missing something more obvious.
Is there another way to determine if the user clicked anywhere outside my TextField
node?