4
$\begingroup$

Why doesn't the following example from the documentation of EventHandler (the very last example) work in the Wolfram programming cloud (WPC)? Is there some kind of workaround?

(*CloudDeploy@*)
DynamicModule[{pos = {0, 0}}, 
 EventHandler[
  Framed@Graphics[{Disk[Dynamic[pos], 0.2]}, 
    PlotRange -> 
     2], {"MouseDown" :> (pos = MousePosition["Graphics"])}]]
$\endgroup$
3
$\begingroup$

I suppose this is far from an ultimate answer to this question, so please forgive me for posting this self Q&A


I'm not sure why this does not work in the Wolfram programming cloud. It seems like the (Wolfram system of the) Wolfram programming cloud does not like redrawing graphics directives without redrawing an entire Graphics expression. The following works, which is just the same code but with the Dynamic wrapper moved to the outside of Graphics.

(*CloudDeploy@*)
DynamicModule[{pos = {0, 0}}, 
 EventHandler[
  Dynamic@Framed@
    Graphics[{Disk[pos, 0.2]}, 
     PlotRange -> 2], {"MouseDown" :> (pos = 
      MousePosition["Graphics"])}]]

Unfortunately this workaround seems to be the direct opposite of the performance improving method of separating directives and making them update independently, which is done in Kuba's answer here.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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