MathGroup Archive 2014

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

Search the Archive

EventHandler in Graphics

  • To: mathgroup at smc.vnet.net
  • Subject: [mg132457] EventHandler in Graphics
  • From: "djmpark" <djmpark at comcast.net>
  • Date: Thu, 20 Mar 2014 05:28:05 -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

Dear MathGroup,

I would like to design a custom slider as a Graphics element. I would like
it to be a Graphics element with everything specified in Graphics
coordinates so I can precisely place the elements.  (I don't want to use
Inset that has unspecified fillings and whose size cannot be given in
graphical coordinates and that does not adjust if the graphic is dragged to
a different size.)

So here is something that pretty much works. The invisible Rectangle
provides the area over which the EventHandler operates. The only problem is
that as soon as the area is clicked the entire graphic is selected. (With
the red box and handles around the graphic.) Is there any way to suppress
that selection? The selection occurs as soon as the area is clicked.

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

] 

 

If one substitutes "MouseClicked" for "MouseDragged" no selection occurs -
as is desired.

 

I was also looking at the idea of  nested EventHandlers but could not find a
single example of its usage in help although they are mentioned in the
EventHandles Details and Options. It is not clear how the nesting would be
arranged. Does anyone have any ideas on that?

 

David Park

djmpark at comcast.net 

http://home.comcast.net/~djmpark/index.html 

 





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