The Math Forum

Search All of the Math Forum:

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

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

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



{Style[Line[{{-1, 0}, {1, 0}}], Antialiasing -> False],



Rectangle[{-1.1, -0.2}, {1.1, 0.2}]},

{"MouseDragged" :> (position = {Clip[

First@MousePosition["Graphics"], {-1, 1}], 0};

xposition = First[position])}],

AbsolutePointSize[7], Red,


PlotRange -> {{-1.5, 1.5}, {-0.5, 0.5}},

Frame -> True,

ImageSize -> 300,

ContentSelectable -> False],



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

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

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.