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.

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.

share|improve this question
    
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. –  Mike Honeychurch Dec 20 '12 at 5:35
    
Try this instead: EventHandler[InputField[Dynamic[s]], {"MouseEntered" :> (Print[1])}] –  Mike Honeychurch Dec 20 '12 at 5:37
add comment

2 Answers

up vote 5 down vote accepted

Try

 EventHandler[InputField[Dynamic[s]], {"MouseClicked" :> (Print[1])}, 
    PassEventsDown -> True]
share|improve this answer
add comment

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.

share|improve this answer
    
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. –  niren Dec 20 '12 at 5:58
    
@user4988 ok. just added a right click alternative. –  Mike Honeychurch Dec 20 '12 at 7:44
add comment

Your Answer

 
discard

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

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