3
$\begingroup$

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$
2
  • $\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, 2015 at 20:55
  • $\begingroup$ the suggested deploy function solved the problem - thanks to all. $\endgroup$
    – Robert
    Apr 7, 2015 at 2:44

0

Browse other questions tagged or ask your own question.