MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Dynamic Module with Trigger


Hi,

> 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?
> 
> 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]
>    }]
>  ]

Is this what you are looking for?

DynamicModule[{a = 3, b}, b = 2;
 Column[{Slider[Dynamic[a, (b = 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]}]]

albert


  • Prev by Date: Re: spatial finite differences in two dimensions (something like
  • Next by Date: Re: Stylesheets
  • Previous by thread: Dynamic Module with Trigger
  • Next by thread: Re: Dynamic Module with Trigger