MathGroup Archive 2009

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

Search the Archive

Re: Dynamic Module with Trigger

  • To: mathgroup at smc.vnet.net
  • Subject: [mg96701] Re: Dynamic Module with Trigger
  • From: Albert Retey <awnl at gmx-topmail.de>
  • Date: Sat, 21 Feb 2009 19:39:23 -0500 (EST)
  • References: <gnm1kr$hdg$1@smc.vnet.net>

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