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

Why won't

EventHandler["text", {"MouseClicked" :> (output = Input[];)}]


When I click "text" the kernel hangs.

share|improve this question
can you expand a little more on what you're trying to do? – kale Aug 24 '12 at 15:11
The real application would be something like, clicking in a graphics object, and saving the coordinates and a label that I input using Input[]... – Peter Aug 24 '12 at 15:13
Is that code what you've been using? It contains an error: "MouseClicked" > action should be "MouseClicked" -> action. – rcollyer Aug 24 '12 at 15:15
I use "MouseClicked" :> action, I corrected the error – Peter Aug 24 '12 at 15:26
Welcome to Mathematica.SE! Let me remind you three things we usually do here: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the FAQs! 3) When you see good Q&A, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. ALSO, remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign` – Vitaliy Kaurov Aug 25 '12 at 8:33
up vote 10 down vote accepted

You are facing an issue similar to described here . The problem is Button has option Method -> "Queued" and EventHandler does not have anything similar. Here is a way around it:

DynamicModule[{output = "click to change"}, Button[Dynamic[output], 
  output = InputString["Enter new text", "click to change"], 
  Method -> "Queued", Appearance -> "Frameless"]]

enter image description here

If you just must use EventHandler, then CreateDialog is a work around:

output = "click to change";
EventHandler[ Dynamic[output], {"MouseClicked" :> 
   CreateDialog[{TextCell["Enter new text"], 
     InputField[Dynamic[output], String], 

enter image description here

share|improve this answer
I thought scheduled tasks could help here, but they have the same problem. Might be because scheduled tasks don't need a frontend and Input probably runs in the frontend? – Sjoerd C. de Vries Aug 25 '12 at 7:08

Your Answer


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.