Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

How might I detect when an InputField comes into focus?

For example ideally something like this would work.

 InputField["default", String], {
  "FocusGained" :> (MessageDialog["Focus"]),
  "FocusLost" :> (MessageDialog["unFocus"]),
  "Focus" :> (MessageDialog["Focus"])

After reading this question I assumed "FocusGained,FocusLost or Focus" would do something but I haven't had any luck just yet.

share|improve this question
In Locator you can achieve this with second argument of Dynamic, however it seems this is not working in InputField. We have to wait for someone who likes digging in notebook expressions or knows how to work with undocumented events. –  Kuba Aug 25 '13 at 17:54
A workaround may be to use "MouseClicked" to trigger "focus" and then use ControllerState["Button 1"] to trigger "unfocus", using "MouseEntered" and "MouseExited" to determine if the click was inside our outside the input box. –  Pickett Aug 25 '13 at 17:57
These are not events for EventHandler but events in GUIKit‌​. –  Michael E2 Aug 26 '13 at 0:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.