I would like to add a Locator
to a figure displayed by Manipulate
when I click inside the figure, at the location where I click, and to have this trigger an update of the figure. I would also like to have clicking on an existing Locator
remove it, and dragging a locator reposition it (again, redrawing the figure in response in each case).
For (a silly) example, I would like clicking anywhere in the region displayed by
With[{locs = {}},
Manipulate[Graphics[Text[locs, {0, 0}], PlotRange -> 2],
{{q, {1, 1}}, Locator,
Appearance -> Graphics[{Green, Disk[{0, 0}, .1]}, ImageSize -> 10]},
{{p, locs}, Locator,
Appearance -> Graphics[{Red, Disk[{0, 0}, .1]}, ImageSize -> 10]}]]
to add the corresponding Point
to locs
, and for clicking on any p
Locator
to remove it from locs
, with the text, updating accordingly in response to additions, deletions or repositionings of a Locator
.
To make things hard, I have another locator q
that needs to coexist with the one to which I would like to add/remove; and p
and q
have different appearances.
Manipulate
that seems to "get in the way": nothing happens when I click, even withLocatorAutoCreate -> All
. $\endgroup$Locator
s by clicking on the location where I want the locator (of the locator I want to remove)? I should have thought that (and not adding at random locations, or removing the last-addedLocator
) was implicit. $\endgroup$