MathGroup Archive 2009

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

Search the Archive

Re: Dynamic Module with Trigger

  • To: mathgroup at smc.vnet.net
  • Subject: [mg96707] Re: Dynamic Module with Trigger
  • From: Hugh Goyder <h.g.d.goyder at cranfield.ac.uk>
  • Date: Sat, 21 Feb 2009 19:40:28 -0500 (EST)
  • References: <gnm1kr$hdg$1@smc.vnet.net>

I am probably making my own problem too complicated. After posting I
came up with an adequate solution whereby I add another variable and
use a second argument in Dynamic for setting the initial condition.
This works, as shown below. The only difficulty is that if the trigger
is interrupted while operating it does not stop and reset.

Thanks
Hugh Goyder

DynamicModule[{a = 3, b, c = 0},
 b = 2;
 Column[{Slider[Dynamic[a, (a = #; c = a) &], {0, 10, 1}],
   Trigger[Dynamic[b, (b = #; c = b + a) &], {0, 25}],
   Row[{Dynamic[{a, b}]}],
   Graphics[{Dynamic[Line[{{0, 0}, {c, 0}}]]},
    PlotRange -> {{0, 40}, {-10, 10}}, Frame -> True,
    ImageSize -> 72 6]}]]

On 20 Feb, 10:45, Hugh Goyder <h.g.d.goy... at cranfield.ac.uk> wrote:
> 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]
>    }]
>  ]



  • Prev by Date: Re: Stylesheets
  • Next by Date: Precise bitmaps
  • Previous by thread: Re: Dynamic Module with Trigger
  • Next by thread: Re: Dynamic Module with Trigger