I have some trouble evolving from this
Manipulate[
Grid[{{"date: ", date}, {"dates: ", dates}}],
{{dates, {1 -> "A", 2 -> "B", 3 -> "C"}}, None},
{{date, 1}, dates, PopupMenu},
Button["Add",
AppendTo[dates,
dates[[-1, 1]] + 1 ->
FromCharacterCode[ToCharacterCode[dates[[-1, 2]]] + 1]]]
]
I whish to attach an "handler" so that when i change the PopupMenu I can do something. I tried this
Manipulate[
If[updated,
Print["updated"];
updated = False
];
Grid[{{"date: ", date}, {"dates: ", dates}}],
{{dates, {1 -> "A", 2 -> "B", 3 -> "C"}}, None},
{{updated, False}, None},
{{date, 1}, dates,
PopupMenu[Append[#, (date = #; updated = True) &], #2[[1]]] &},
Button["Add",
AppendTo[dates,
dates[[-1, 1]] + 1 ->
FromCharacterCode[ToCharacterCode[dates[[-1, 2]]] + 1]]]
]
but the PopupMenu
is not displayed.
The following code display the PopupMenu
but it's not linked to the variable.
Manipulate[
If[updated,
Print["updated"];
updated = False
];
Grid[{{"date: ", date}, {"dates: ", dates}}],
{{dates, {1 -> "A", 2 -> "B", 3 -> "C"}}, None},
{{updated, False}, None},
{{date, 1}, {1 -> "A", 2 -> "B", 3 -> "C"},
PopupMenu[Append[#, (date = #; updated = True) &], #2[[1]]] &},
Button["Add",
AppendTo[dates,
dates[[-1, 1]] + 1 ->
FromCharacterCode[ToCharacterCode[dates[[-1, 2]]] + 1]]]
]
If possible I whish to use Manipulate and declare the local variable date
and consume it at the same place.