• No results found

mouse-event%

In document The Racket Graphical Interface Toolkit (Page 106-111)

mouse-event% : class?

superclass: event%

Amouse-event%object encapsulates a mouse event. Mouse events are primarily processed byon-subwindow-eventinwindow<%>andon-eventincanvas<%>.

See also §1.5 “Mouse and Keyboard Events”.

(new mouse-event%

(or/c 'enter 'leave 'left-down 'left-up 'middle-down 'middle-up

'right-down 'right-up 'motion) left-down : any/c = #f

middle-down : any/c = #f right-down : any/c = #f x : exact-integer? = 0 y : exact-integer? = 0 shift-down : any/c = #f control-down : any/c = #f meta-down : any/c = #f alt-down : any/c = #f

time-stamp : exact-integer? = 0 caps-down : any/c = #f

Creates a mouse event for a particular type of event. The event types are:

• 'enter— mouse pointer entered the window

• 'leave— mouse pointer left the window

• 'left-down— left mouse button pressed

• 'left-up— left mouse button released

• 'middle-down— middle mouse button pressed

• 'middle-up— middle mouse button released

• 'right-down — right mouse button pressed (Mac OS X: click with control key pressed)

• 'right-up — right mouse button released (Mac OS X: release with control key pressed)

• 'motion— mouse moved, with or without button(s) pressed

See the correspondingget-andset-methods for information aboutleft-down, middle-down,right-down,x,y,shift-down,control-down,meta-down,alt-down, time-stamp, andcaps-down.

(send a-mouse-event button-changed? [button]) → boolean?

button : (or/c 'left 'middle 'right 'any) = 'any

Returns#tif this was a mouse button press or release event,#fotherwise. See also button-up?andbutton-down?.

Ifbutton is not'any, then#tis only returned if it is a release event for a specific button.

(send a-mouse-event button-down? [button]) → boolean?

button : (or/c 'left 'middle 'right 'any) = 'any

Returns#tif the event is for a button press,#fotherwise.

Ifbutton is not'any, then#tis only returned if it is a press event for a specific button.

(send a-mouse-event button-up? [button]) → boolean?

button : (or/c 'left 'middle 'right 'any) = 'any

Returns#tif the event is for a button release,#fotherwise. (As noted in §1.5 “Mouse and Keyboard Events”, button release events are sometimes dropped.)

Ifbutton is not'any, then#tis only returned if it is a release event for a specific button.

(send a-mouse-event dragging?) → boolean?

Returns#tif this was a dragging event (motion while a button is pressed),#fotherwise.

(send a-mouse-event entering?) → boolean?

Returns#tif this event is for the mouse entering a window,#fotherwise.

When the mouse button is up, an enter/leave event notifies a window that it will start/stop receiving mouse events. When the mouse button is down, however, the window receiving the mouse-down event receives all mouse events until the button is released; enter/leave events are not sent to other windows, and are not reliably delivered to the click-handling window (since the window can detect movement out of its region viaget-xandget-y). See also

§1.5 “Mouse and Keyboard Events”.

(send a-mouse-event get-alt-down) → boolean?

Returns #tif the Option (Mac OS X) key was down for the event. When the Alt key is pressed in Windows, it is reported as a Meta press (seeget-meta-down).

(send a-mouse-event get-caps-down) → boolean?

Returns#tif the Caps Lock key was on for the event.

(send a-mouse-event get-control-down) → boolean?

Returns#tif the Control key was down for the event.

On Mac OS X, if a control-key press is combined with a mouse button click, the event is reported as a right-button click andget-control-downfor the event reports#f.

(send a-mouse-event get-event-type)

(or/c 'enter 'leave 'left-down 'left-up 'middle-down 'middle-up

'right-down 'right-up 'motion)

Returns the type of the event; seemouse-event%for information about each event type. See alsoset-event-type.

(send a-mouse-event get-left-down) → boolean?

Returns#tif the left mouse button was down (but not pressed) during the event.

(send a-mouse-event get-meta-down) → boolean?

Returns#tif the Meta (Unix), Alt (Windows), or Command (Mac OS X) key was down for the event.

(send a-mouse-event get-middle-down) → boolean?

Returns#tif the middle mouse button was down (but not pressed) for the event. On Mac OS X, a middle-button click is impossible.

(send a-mouse-event get-right-down) → boolean?

Returns#tif the right mouse button was down (but not pressed) for the event. On Mac OS X, a control-click combination is treated as a right-button click.

(send a-mouse-event get-shift-down) → boolean?

Returns#tif the Shift key was down for the event.

(send a-mouse-event get-x) → exact-integer?

Returns the x-position of the mouse at the time of the event, in the target’s window’s (client-area) coordinate system.

(send a-mouse-event get-y) → exact-integer?

Returns the y-position of the mouse at the time of the event in the target’s window’s (client-area) coordinate system.

(send a-mouse-event leaving?) → boolean?

Returns#tif this event is for the mouse leaving a window,#fotherwise.

See entering?for information about enter and leave events while the mouse button is clicked.

(send a-mouse-event moving?) → boolean?

Returns#tif this was a moving event (whether a button is pressed is not),#fotherwise.

(send a-mouse-event set-alt-down down?) → void?

down? : any/c

Sets whether the Option (Mac OS X) key was down for the event. When the Alt key is pressed in Windows, it is reported as a Meta press (seeset-meta-down).

(send a-mouse-event set-caps-down down?) → void?

down? : any/c

Sets whether the Caps Lock key was on for the event.

(send a-mouse-event set-control-down down?) → void?

down? : any/c

Sets whether the Control key was down for the event.

On Mac OS X, if a control-key press is combined with a mouse button click, the event is reported as a right-button click andget-control-downfor the event reports#f.

(send a-mouse-event set-event-type event-type) → void?

event-type :

(or/c 'enter 'leave 'left-down 'left-up 'middle-down 'middle-up

'right-down 'right-up 'motion)

Sets the type of the event; seemouse-event%for information about each event type. See alsoget-event-type.

(send a-mouse-event set-left-down down?) → void?

down? : any/c

Sets whether the left mouse button was down (but not pressed) during the event.

(send a-mouse-event set-meta-down down?) → void?

down? : any/c

Sets whether the Meta (Unix), Alt (Windows), or Command (Mac OS X) key was down for the event.

(send a-mouse-event set-middle-down down?) → void?

down? : any/c

Sets whether the middle mouse button was down (but not pressed) for the event. On Mac OS X, a middle-button click is impossible.

(send a-mouse-event set-right-down down?) → void?

down? : any/c

Sets whether the right mouse button was down (but not pressed) for the event. On Mac OS X, a control-click combination by the user is treated as a right-button click.

(send a-mouse-event set-shift-down down?) → void?

down? : any/c

Sets whether the Shift key was down for the event.

(send a-mouse-event set-x pos) → void?

pos : exact-integer?

Sets the x-position of the mouse at the time of the event in the target’s window’s (client-area) coordinate system.

(send a-mouse-event set-y pos) → void?

pos : exact-integer?

Sets the y-position of the mouse at the time of the event in the target’s window’s (client-area) coordinate system.

In document The Racket Graphical Interface Toolkit (Page 106-111)