What I am trying to do is modify the standard ClickPane
example where a list of points (pts
) is added to with each click, in the following way: when a click occurs, some sort of choice window appears, and the user then clicks on one of the options. This is added as a third element in each point, so that pts
becomes a list of {x,y,text}
triples (and incidentally gets displayed on the graphic using Text[]
).
Here's the starting point that includes the triples
pts = {{0, 0, "No ID"}};
DynamicModule[{},
ClickPane[
Dynamic@Framed@Graphics[
Map[Text[#[[3]], #[[{1, 2}]]] &, pts],
PlotRange -> 1,
Axes -> True],
AppendTo[pts, Append[#, "No ID"]] &]]
The simplest thing I tried is to replace the "No ID" with a Choice Dialog
speciesList = {"No ID", "Oak", "Sycamore", "Plane", "Birch",
"Ginko", "Ash", "Beech", "Cherry", "Maple"};
pts = {{0, 0, "No ID"}};
DynamicModule[{},
ClickPane[
Dynamic@Framed@Graphics[
{Point[pts[[All, {1, 2}]]]},
PlotRange -> 1,
Axes -> True],
AppendTo[pts, Append[#, ChoiceDialog["Pick one", speciesList]]] &]]
This does cause a choice dialog to pop up, but the dynamic evaluation seems to go into a spin and I have to abort. Any thoughts on what is going wrong would be appreciated.
What I would really like to do is have a PopupMenu
appear right there at the click point (because input dialogs appear floating in the middle of the screen, which can be a long way away), but that seems harder...
DynamicModule[{}, ClickPane[Graphics[], ChoiceDialog["?", {1 -> "a", 2 -> "b"}] &]]
$\endgroup$