Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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. – C. E. 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.