3
$\begingroup$

This question already has an answer here:

There is a problem clicking layered Graphics objects after using Deploy. For example, the code below works as intended with the Disk 'on top of' the Line. Click either object anywhere and EventHandler changes the color as expected.

disk :=
DynamicModule[
  {col = Green},
  EventHandler[
  Dynamic[{col, 
  Disk[]}], {"MouseClicked" :> (col = 
  col /. {Red -> Green, Green -> Red})}]
];

rect :=
 DynamicModule[
  {col = Green},
  EventHandler[
   Dynamic[{col, Thick, 
     Line[{{0, 0}, {10, 1}}]}], {"MouseClicked" :> (col = 
       col /. {Red -> Green, Green -> Red})}]
 ];

Graphics[{ rect, disk}]

Now try this:

Deploy@Graphics[{ rect, disk}]

You will see that EventHandler now behaves as though the Line is on top of the Disk. Is there a workaround. We don't want the user to change / delete the graphic by mistake.

$\endgroup$

marked as duplicate by Kuba, C. E., ciao, bbgodfrey, Oleksandr R. Apr 7 '15 at 0:50

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • $\begingroup$ This is due to the known bug. Don't have 10.1 but it was still there in 10.0.2. Answers to the question provide work arounds. 43672 $\endgroup$ – Kuba Apr 6 '15 at 20:55
  • $\begingroup$ the suggested deploy function solved the problem - thanks to all. $\endgroup$ – Robert Apr 7 '15 at 2:44