I have a problem with PopupMenu
inside DynamicModule
, its values don't update dynamically as they supposed to. The example below demonstrates the issue.
DynamicModule[{inputData = 0, dataSet1 = {0}, popupSelection, value1, value2 },
Dynamic@Column[{
InputField[Dynamic[inputData]],
Button["Plot", dataSet1 = Table[inputData + i^j, {i, 5}, {j, 2}]],
Spacer[5],
PopupMenu[Dynamic[popupSelection], {value1 -> "v1", value2 -> "v2"}],
ListPlot[popupSelection, Joined -> True, ImageSize -> {300},
Frame -> True]}],
Initialization :> (
value1 = dataSet1;
value2 = dataSet1 + 1;
),
SynchronousInitialization -> False]
The PopupMenu
is linked to ListPlot
, for example: if value1
with label "v1" is selected from the list then ListPlot should print the evaluated value of value1
and the same goes for value2
.
The problem I have is that value1
and value2
which correspond to popupSelection
don't update dynamically when changing the input of InputField
and pressing button "Plot". These values evaluate only once (upon DynamicModule
evaluation) using initial values and they do not re-evaluate when required. I tried to wrap expressions of value1
and value2
with Dynamic
but it conflicts with ListPlot
giving me bunch of error messages.
I know i'm missing something here, I just can't figure out what it is. Please help!