Consider the following piece of code from Heike as an ( accepted ) answer on LocatorPane, selecting multiple Locators - Basically the code implements dragging polygons on a LocatorPane.
DynamicModule[{pts, range, gr, drag, pts0},
pts = RandomReal[1, {7, 2}];
range = {1 ;; 4, 5 ;; 7};
gr = {{Red, Polygon @ Dynamic @ pts[[ range[[1]] ]]},
{Blue, Polygon @ Dynamic @ pts[[ range[[2]] ]]}};
drag = 0;
Panel[LocatorPane[Dynamic[pts],
EventHandler[
Graphics[
EventHandler[gr[[#1]],
{"MouseDown" :>
(drag = #; pts0 = # - MousePosition["Graphics"] & /@ pts[[ range[[#]] ]])}
] & /@ {1, 2},
PlotRange -> {{0, 2}, {0, 2}}],
{"MouseDragged" :>
If[drag > 0, pts[[range[[drag]]]] = # + MousePosition["Graphics"] & /@ pts0],
"MouseUp" :> (drag = 0)},
PassEventsDown -> True
]
]]
]
If you run this code you'll notice that when a locator's position is on another polygon the locator does not work anymore.
Question: How can the code above be changed so that a click on a locator always works? Why was it necessary to use two two EventHandlers, and what is a good rule to decide on wether to use the PassEventsDown option?
