I try to edit InputField while using EventHandler's MouseClicked, but the InputField is not editable. I tried like this

EventHandler[InputField[Dynamic[s]], {"MouseClicked" :> (Print[1])}]

When i Click on InputField it print 1 but the InputField is not editable.

  • $\begingroup$ What is happening is that by wrapping in event handler you are saying that whenever you click within the area in which the event occurs (the mouse click) you will print. This means by assigning a mouse click as an event you are removing the ability to click in the input field. $\endgroup$ Commented Dec 20, 2012 at 5:35
  • $\begingroup$ Try this instead: EventHandler[InputField[Dynamic[s]], {"MouseEntered" :> (Print[1])}] $\endgroup$ Commented Dec 20, 2012 at 5:37

2 Answers 2



 EventHandler[InputField[Dynamic[s]], {"MouseClicked" :> (Print[1])}, 
    PassEventsDown -> True]

I guess my comment could be an answer. You need to be able to click in the input field but you have assigned mouse clicks to some other event -- in this case printing. So another way to get something to happen when the mouse is "in" the input field is to use "MouseEntered"

EventHandler[InputField[Dynamic[s]], {"MouseEntered" :> (Print[1])}]

But whether this is appropriate would depend on what your actual problem is (I"m assuming this is a toy example).

Another alternative is to right click in the field:

EventHandler[InputField[Dynamic[s]], {{"MouseClicked", 2} :> (Print[1])}]

but for a left click within the input field @kguler's solution looks like it is what you need.

  • $\begingroup$ I tried your idea but i want to print 1 only when mouse clicked on Inputfield And Don't want to print it before click. $\endgroup$
    – niren
    Commented Dec 20, 2012 at 5:58
  • $\begingroup$ @user4988 ok. just added a right click alternative. $\endgroup$ Commented Dec 20, 2012 at 7:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.