Hello everyone! I'm rather new to Mathematica, and although I understand the basics regarding Module, Block, and DynamicModule, I have come across some unexpected behavior when I use Manipulate to change the graph to be plotted when inside a DynamicModule. Below is the code for when I wrap the Manipulate with DynamicModule:
DynamicModule[{x, y},
x[t_] := t^2 + 5;
y[t_] := t^3 + 5;
Manipulate[Plot[fcn[t], {t, -5, 5}],
{fcn, {x, y}}
]
]
And here is the result:
The SetterBar behaves as expected when you click between the square function and the cubic function (with the square function selected above), but the SetterBar looks differently than the following code:
x[t_] := t^2 + 5;
y[t_] := t^3 + 5;
Manipulate[Plot[fcn[t], {t, -5, 5}],
{fcn, {x, y}}
]
I understand that the variable names are different between the two examples because DynamicModule localizes the variables (by adding $$ and numbers after the variable name), but why did the highlighting functionality stop working? It is also a curious thing to note that replacing DynamicModule with either Block or Module will produce the expected behavior for the SetterBar.
One other thing I noticed - Why is the function not offset by 5 like expected?