As surmised by @Sjoerd in the question's comments, Manipulate
combines all locators into a single LocatorPaneBox
. We can see this if we inspect the boxes generated by the Manipulate
expression:
PaneBox[PanelBox[DynamicWrapperBox[PaneSelectorBox[{True->GridBox[{{
...
LocatorPaneBox[
Dynamic[{$CellContext`point1$$,$CellContext`point2$$}],
...
Enabled->False,Enabled->True]
...
FrameMargins->{{5,5},{5,5}}],ImageMargins->0,BaselinePosition->Automatic]
This excerpted snippet shows us two things. First, we can see the single LocatorPaneBox
that references both points. Second, we can see that the Enabled
option is specified twice. As usual, the first instance takes precedence over the second with the result that both locators are disabled. This second point feels like a bug.
To work around this problem is tricky. We could try to use an explicit LocatorPane
, but that does not allow us to specify independent regions or enablement states for each locator. If we try to use two LocatorPane
expressions, we run into problems when the outer pane is disabled -- events do not get sent down to the inner pane. It is possible to work around this using elaborate EventHandler
interactions, but it is not pretty. I suspect that these problems are what led to the present restrictions in the Manipulate
implementation.
In this particular case, a simpler solution is to abandon LocatorPane
altogether and to include explicit Locator
directives instead:
clip[pt:{x_, y_}, {xMin_, yMin_}, {xMax_, yMax_}, {xStep_, yStep_}] :=
{Round[Clip[x, {xMin, xMax}], xStep], Round[Clip[y, {yMin, yMax}], yStep]}
Manipulate[
Graphics[
{ Arrow[{{0, 0}, point1}]
, Arrow[{{0, 0}, point2}]
, Locator[Dynamic[point1,(point1=clip[#, {-4, -4}, {8, 8}, {.1, .1}])&], Enabled->False]
, Locator[Dynamic[point2,(point2=clip[#, {-3, -3}, {6, 6}, {.1, .1}])&], Enabled->True]
}
, Axes -> True, PlotRange -> {{-4, 8}, {-4, 8}}
]
, {{point1, {-1, 3}}, None}
, {{point2, {5, -2}}, None}
]
Unfortunately, this means that we must implement the locator region constraints ourselves since Locator
does not offer that service (LocatorRegion
only provides crude clipping). However, this is easier than the event-handling gymnastics that would otherwise be required for LocatorPane
.
Enabled
encountered determines the state of all. There is some hint (it's not precisely your situation) about the internal difficulties involved in combining multiple locators in the documentation: "Due to internal limitations, it is not possible to combine individual Locator variables with a variable that is a list of multiple Locator variables: you can have only one multipoint Locator variable in a Manipulate." $\endgroup$Locator
section, between In[36] and In[37]). $\endgroup$