4

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"])}]]
Jacob Akkerboom
  • 12,215
  • 45
  • 79

1 Answers1

3

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.

Jacob Akkerboom
  • 12,215
  • 45
  • 79