Unfocus TextEditor when user clicks off


#1

When the user clicks outside of textEditor I want the TextEditor to lose focus. Whats the best way to do this?


#2

(Thankyou for spelling "lose" correctly. I think you must be in the minority on this forum!)

It will of course lose focus if something else gets focus, so you'd just need to make sure that whatever other component you expect the user to click on is set up to accept focus.


#3

For accepting focus is using setWantsKeyboardFocus(true) the correct way? 


#4

Yep. There are a few methods in component for controlling the way focus is passed around, but that's the main one.