This issue was raised as an offside problem in this thread. Consider the following example, that does not work as expected:
Manipulate[{x, r}, {{x, r}}, {r, 0, 1}]
Note that as r
is manipulated the InputField
of x
is updated (as the initial value of x
is set to be r
) but not the x
displayed as the body of the Manipulate
. Interestingly, if x
depends on r
in a different way (endpoints of range instead of initial value) the example works as expected: whenever r
is changed it changes both the displayed values of x
:
Manipulate[{x, r}, {x, r, 1}, {r, 0, 1}]
It seems like that in Manipulate
changing a variable (r
) does not trigger a re-evaluation of the initial-value-dependent variable (x
) displayed in the body though its value displayed in the control is updated correctly.
I have no idea why the first example does not work the same way as the second does. While it might be said that this is a feature, I would argue that the unexplained decoupling of the two representations of x
(as body and control) is quite disturbing.
Workarounds
The re-evaluation can be triggered by making
x
dynamic:Manipulate[{Dynamic[x], r}, {{x, r}}, {r, 0, 1}]
Moving the definition of
x
out of the control-arguments to the body of theManipulate
:Manipulate[{x = r, r}, {r, 0, 1}]
Rewriting it in
DynamicModule
: it has an explicit function inside theDynamic
ofr
that setsx
wheneverr
is modified:Panel@DynamicModule[{x, r = .5}, x = r; Grid[{ {"x", InputField[Dynamic[x]]}, {"r", Slider[Dynamic[r, (r = #; x = #) &], {0, 1}]}, {Panel[Dynamic@{x, r}], SpanFromLeft} }, Alignment -> Left] ]