LocatorPane: turn off "direct any click to nearest locator"?
- To: mathgroup at smc.vnet.net
- Subject: [mg78707] LocatorPane: turn off "direct any click to nearest locator"?
- From: Tom <thomasan at gmail.com>
- Date: Sat, 7 Jul 2007 06:06:18 -0400 (EDT)
Is there any way to change the behavior of LocatorPane so that it
ignores clicks that are not on any of the locators? I want to be able
to click on individual locators and drag them around, but I don't want
stray clicks on white space to affect the locators. The documentation
for LocatorPane says that "LocatorPane[pts,back,range] by default
directs any click to the nearest locator." This seems to imply that
this behavior can be turned off. I have tried all of the available
options for LocatorPane, along with some unavailable ones :), with no
success.
Basically, what I'm looking for is a LocatorPane that acts like a
(dynamic) set of Locators. With a Locator, you have to click on the
Locator itself (and then drag) to change its position.
The closest I've come to the behavior I want is shown below: I put a
test in the Dynamic list of points displayed by the locators, that
only accepts location changes within a defined dx and dy. This works,
but it has the side effect of not registering fast dragging of the
locators.
DynamicModule[{pts = {{0, 0}, {1, 1}, {2, 2}}},
LocatorPane[
Dynamic[pts, (pts = If[Max[Abs[Flatten[# - pts]]] < 0.05, #, pts])
&],
Graphics[{Dynamic[Line[pts]]}]]]
I've also tried using a dynamic list of Locators, but that doesn't
seem to work. I could probably "roll my own" using an EventHandler,
but I'd rather use the probably-more-robust LocatorPane.
Thanks for any advice,
Tom