Dynamic Module with Trigger
- To: mathgroup at smc.vnet.net
- Subject: [mg96671] Dynamic Module with Trigger
- From: Hugh Goyder <h.g.d.goyder at cranfield.ac.uk>
- Date: Fri, 20 Feb 2009 05:45:50 -0500 (EST)
In the toy DynamicModule below pressing the trigger makes an existing
line longer. The initial length of the line is controlled by a slider.
The module works but I want to add the feature that when I move the
slider the trigger resets itself and the now changed initial line is
drawn. Is it possible to do this?
Thanks
Hugh Goyder
DynamicModule[
{a = 3, b},
b = 2;
Column[{
Slider[Dynamic[a], {0, 10, 1}],
Trigger[Dynamic[b, (b = #; b = b + a) &], {0, 25}],
Row[{Dynamic[{a, b}]}],
Graphics[{Dynamic[Line[{{0, 0}, {b, 0}}]]},
PlotRange -> {{0, 40}, {-10, 10}}, Frame -> True,
ImageSize -> 72 6]
}]
]