Questions about Locators
- To: mathgroup at smc.vnet.net
- Subject: [mg98188] Questions about Locators
- From: Patrick Scheibe <pscheibe at trm.uni-leipzig.de>
- Date: Wed, 1 Apr 2009 06:00:00 -0500 (EST)
Hi,
I have two related questions.
Assuming the following minimal example where you have a LocatorPane
and you count the numbers of
update calls:
DynamicModule[{pt = {{0, 0}}, c = 0},
Column[{LocatorPane[Dynamic[pt, (pt = #1; c++) & ],
Graphics[{Yellow, Rectangle[{0, 0}, {1, 1}]},
PlotRange -> {{0, 1}, {0, 1}}, Frame -> False],
LocatorAutoCreate -> True], Dynamic[c], Dynamic[pt]}]]
If I move the Locator, the count and the position is updated as
expected. When you add a Locator with
Alt+Click then you get an update call too as one would expect since
pt is dynamically changed.
But that is not the case if you delete one Locator with Alt+Click on
an existing one. I'm wondering why the
variable pt is updated but c variable stays unchanged. Any ideas?
What you can see in the above sample is, that when you grab a
locator, it is centered under the mouse cursor. If I take another
small sample not using a LocatorPane but a Graphics this does not
happen.
DynamicModule[{x = 0.5, y = 0.5},
Column[{Deploy[Graphics[Locator[Dynamic[{x, y}],
LocatorRegion -> Automatic], PlotRange -> {{0, 1}, {0,
1}}]],
Dynamic[{x, y}]}]]
The intention of the LocatorRegion->Automatic option is to prevent
the locator to go outside the given PlotRange. Without success
as one can test by grabbing the Locator at one side and not at the
center. Is there a way to achieve the same behaviour for a
normal Locator as in a LocatorPane?
Cheers
Patrick