MathGroup Archive 2014

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

Search the Archive

Re: EventHandler in Graphics

  • To: mathgroup at smc.vnet.net
  • Subject: [mg132459] Re: EventHandler in Graphics
  • From: W Craig Carter <ccarter at MIT.EDU>
  • Date: Sat, 22 Mar 2014 00:05:41 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-outx@smc.vnet.net
  • Delivered-to: mathgroup-newsendx@smc.vnet.net
  • References: <20140320092805.AC1936A1D@smc.vnet.net>

Hello David,
I wrapped Deploy around your Graphics[__] and I think it does what you want.

DynamicModule[{position = {0, 0}, xposition = 0}, 
 Column[{Deploy@
    Graphics[{Style[Line[{{-1, 0}, {1, 0}}], Antialiasing -> False], 
      EventHandler[{FaceForm[Opacity[0.0]], 
        Rectangle[{-1.1, -0.2}, {1.1, 
          0.2}]}, {"MouseDragged" :> (position = {Clip[
             First@MousePosition["Graphics"], {-1, 1}], 0};
          xposition = First[position])}], AbsolutePointSize[7], Red, 
      Point[Dynamic[position]]}, 
     PlotRange -> {{-1.5, 1.5}, {-0.5, 0.5}}, Frame -> True, 
     ImageSize -> 300, ContentSelectable -> False], 
   Dynamic@xposition}]]



Kind Regards,
Craig




On Mar 20, 14, at 5:28 AM, djmpark <djmpark at comcast.net> wrote:

> DynamicModule[{position = {0, 0}, xposition = 0},
> 
> Column[{
> 
>   Graphics[
> 
>    {Style[Line[{{-1, 0}, {1, 0}}], Antialiasing -> False],
> 
>     EventHandler[
> 
>      {FaceForm[Opacity[0.0]],
> 
>       Rectangle[{-1.1, -0.2}, {1.1, 0.2}]},
> 
>      {"MouseDragged" :> (position = {Clip[
> 
>            First@MousePosition["Graphics"], {-1, 1}], 0}; 
> 
>         xposition = First[position])}],
> 
>     AbsolutePointSize[7], Red,
> 
>     Point[Dynamic[position]]},
> 
>    PlotRange -> {{-1.5, 1.5}, {-0.5, 0.5}},
> 
>    Frame -> True,
> 
>    ImageSize -> 300,
> 
>    ContentSelectable -> False],
> 
>   Dynamic@xposition}]
> 
> ] 




  • Prev by Date: Re: EventHandler in Graphics
  • Next by Date: Re: Mapping tag-value lists to a third
  • Previous by thread: Re: EventHandler in Graphics
  • Next by thread: Problems with Solve