10
$\begingroup$

How might I detect when an InputField comes into focus?

For example ideally something like this would work.

EventHandler[ 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.

$\endgroup$
2
  • 1
    $\begingroup$ 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. $\endgroup$ Commented Aug 25, 2013 at 17:57
  • 1
    $\begingroup$ These are not events for EventHandler but events in GUIKit. $\endgroup$ Commented Aug 26, 2013 at 0:33

1 Answer 1

1
$\begingroup$

No, there is not anything documented that supports those events directly.

With so many folks digging up undocumented features I think it is safe to say that there isn't anything undocumented either.

There is a possibility of playing with indirect methods, e.g. listening to SelectionData etc. but I don't think it will give us a general tool, or a scalable one.

Maybe someonce will try to cook something up with this idea, meanwhile I think it is worth to take this on from an unanswered stack.

$\endgroup$
2
  • $\begingroup$ I'm assuming "meanwhile I think it is worth to take this on from an unanswered stack" means there is no sense in leaving this question unanswered when there is certainly not a clear answer. $\endgroup$ Commented Feb 28, 2018 at 3:26
  • $\begingroup$ @William something like that, maybe better "the answer is no but it may be that someone will provide a case specific trick". $\endgroup$ Commented Feb 28, 2018 at 7:01

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.