Why won't
EventHandler["text", {"MouseClicked" :> (output = Input[];)}]
work?
When I click "text" the kernel hangs.
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"]]
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],
DefaultButton[DialogReturn[output]]}]}]
"MouseClicked" > action
should be"MouseClicked" -> action
. $\endgroup$Read the FAQs
! 3) When you see good Q&A, vote them up byclicking 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
` $\endgroup$