Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #16679

Re: EventHandler in Graphics

From W Craig Carter <ccarter@MIT.EDU>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: EventHandler in Graphics
Date 2014-03-22 04:08 +0000
Message-ID <lgj2bj$lca$1@smc.vnet.net> (permalink)
References <20140320092805.AC1936A1D@smc.vnet.net>
Organization Time-Warner Telecom

Show all headers | View raw


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

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar


Thread

Re: EventHandler in Graphics W Craig Carter <ccarter@MIT.EDU> - 2014-03-22 04:08 +0000

csiph-web