This is the simplest version of what you want. The Manipulate
objects are printed right under the plot.
list1 = {{{0, 1}, {1, 2}, {2, 4}}, {{0, 3}, {1, 1}, {2, 5}}};
names = {"curve1", "curve2"};
dummyFunction[t_, u_] := Graphics[{If[u == 1, Green, Red], Disk[], Black, Text[t]}];
ListLinePlot[MapThread[
Tooltip[EventHandler[#, {"MouseClicked" :>
CellPrint[Manipulate[dummyFunction[#2,
variable], {variable, {0, 1}}]]}], #2] &, {list1, names}]]
It has the issue that every time a curve is clicked, a new Manipulate
is printed. To overcome this problem and only show one of the Manipulate
s at a time, introduce an extra switch (show
) that records whichever curve was clicked, and a variable that stores the actual Manipulate
(menu
).
list1 = {{{0, 1}, {1, 2}, {2, 4}}, {{0, 3}, {1, 1}, {2, 5}}};
names = {"curve1", "curve2"};
show = 0;
menu = Spacer@0;
dummyFunction[t_, u_] := Graphics[{If[u == 1, Green, Red], Disk[], Black, Text[t]}];
Column@{
ListLinePlot[
MapThread[
Tooltip[EventHandler[#1, {"MouseClicked" :>
If[show =!= #3, show = #3;
menu = Manipulate[dummyFunction[#2, variable], {variable, {0, 1}}],
show = 0; menu = Spacer@0]}], #2] &, {list1, names,
Range@Length@names}]],
Dynamic@menu}
Even more convenient is the following setup where the appearing menu is directly inserted in ListLinePlot
result:
list1 = {{{0, 1}, {1, 2}, {2, 4}}, {{0, 3}, {1, 1}, {2, 5}}};
names = {"curve1", "curve2"};
selected = None;
dummyFunction[t_, u_] := Graphics[{If[u == 1, Green, Red], Disk[],
Black, Style[Text[t], 14]}, ImageSize -> 40]
Dynamic[ListLinePlot[MapThread[EventHandler[#2,
"MouseDown" :> (
menuPos = MousePosition["Graphics"];
selected = #1;
menu = Grid[{{
Manipulate[dummyFunction[names[[#1]], x], {x, {0, 1}}],
Button["X", selected = None; menu = Spacer@0, ImageSize -> {20, 20}]
}}, Spacings -> 0, Alignment -> Top]),
PassEventsDown -> False, PassEventsUp -> False] &,
{Range@Length@list1, list1}],
PlotStyle -> {{Thick, If[selected === 1, Dashed, {}], Red}, {Thick,
If[selected === 2, Dashed, {}], Blue}}, ImageSize -> 400,
Epilog -> If[selected =!= None, Inset[menu, menuPos], {}]],
TrackedSymbols :> {menuPos, selected, menu}]

Edit
The second approach, in its package-ready function form:
f[list_, names_] := DynamicModule[{show = 0, menu = Spacer@0, dummy},
dummy[t_, u_] :=
Graphics[{If[u == 1, Green, Red], Disk[], Black, Text@t},
ImageSize -> 60];
Column@{ListLinePlot[
MapThread[
Tooltip[EventHandler[#1, {"MouseClicked" :> If[show =!= #3,
show = #3;
menu = Manipulate[
dummy[#2, variable], {variable, {0, 1}}],
show = 0; menu = Spacer@0
]}], #2] &, {list, names, Range@Length@names}]],
Dynamic@menu}
];
list = {{{0, 1}, {1, 2}, {2, 4}}, {{0, 3}, {1, 1}, {2, 5}}};
names = {"curve1", "curve2"};
Manipulate[f[list, names], {t, {"a", "b"}}]