Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: EventHandler in Graphics
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
David Park

Posts: 1,560
Registered: 5/19/07
EventHandler in Graphics
Posted: Mar 20, 2014 5:28 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply


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@comcast.net

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








Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.