Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically unfocus a TextField?

On my view I only have one editable content: Text in a TextField. The problem is that as a user one never gets rid of the focus (because there is nothing else to focus on), once the TextField is focused. I want to remove the focus from the TextField when the user presses Enter. I know how to react to the Enter key being pressed, but I don't know how to unfocus a control/TextField programmatically?

Thanks for any hint!

like image 371
stefan.at.wpf Avatar asked Jan 15 '23 05:01

stefan.at.wpf


1 Answers

I admit I crossposted, but I got a reply there which I want to share here:

Call requestFocus() on the parent, e.g. in my case the HBox containing the TextField.

Full example on https://forums.oracle.com/forums/thread.jspa?messageID=10852574

like image 66
stefan.at.wpf Avatar answered Jan 22 '23 11:01

stefan.at.wpf