h1(#wxmouseevent). Wx::MouseEvent
This event class contains information about the events generated by the mouse:
they include mouse buttons press and release events and mouse move events.
All mouse events involving the buttons use @MOUSE_BTN_LEFT@ for the
left mouse button, @MOUSE_BTN_MIDDLE@ for the middle one and
@MOUSE_BTN_RIGHT@ for the right one. Note that not all mice have a
middle button so a portable application should avoid relying on the events from
it.
*NB:* Note that under Windows CE mouse enter and leave events are not natively supported
by the system but are generated by Widgets itself. This has several
drawbacks: the LEAVE_WINDOW event might be received some time after the mouse
left the window and the state variables for it may have changed during this
time.
*NB:* Note the difference between methods like
"left_down":#MouseEvent_leftdown and
"left_is_down":#MouseEvent_leftisdown: the former returns @true@
when the event corresponds to the left mouse button click while the latter
returns @true@ if the left mouse button is currently being pressed. For
example, when the user is dragging the mouse you can use
"left_is_down":#MouseEvent_leftisdown to test
whether the left mouse button is (still) depressed. Also, by convention, if
"left_down":#MouseEvent_leftdown returns @true@,
"left_is_down":#MouseEvent_leftisdown will also return @true@ in
Widgets whatever the underlying GUI behaviour is (which is
platform-dependent). The same applies, of course, to other mouse buttons as
well.
h2. Derived from
"Event":event.html
h2. Event table macros
To process a mouse event, use these event handler macros to direct input to member
functions that take a MouseEvent argument.
|*evt_left_down() { | event | ... }*|Process a EVT_LEFT_DOWN event. Thehandler of this event should normally call "event.Skip()":eventskip.html toallow the default processing to take place as otherwise the window under mousewouldn't get the focus.|
|*evt_left_up() { | event | ... }*|Process a EVT_LEFT_UP event.|
|*evt_left_dclick() { | event | ... }*|Process a EVT_LEFT_DCLICK event.|
|*evt_middle_down() { | event | ... }*|Process a EVT_MIDDLE_DOWN event.|
|*evt_middle_up() { | event | ... }*|Process a EVT_MIDDLE_UP event.|
|*evt_middle_dclick() { | event | ... }*|Process a EVT_MIDDLE_DCLICK event.|
|*evt_right_down() { | event | ... }*|Process a EVT_RIGHT_DOWN event.|
|*evt_right_up() { | event | ... }*|Process a EVT_RIGHT_UP event.|
|*evt_right_dclick() { | event | ... }*|Process a EVT_RIGHT_DCLICK event.|
|*evt_motion() { | event | ... }*|Process a EVT_MOTION event.|
|*evt_enter_window() { | event | ... }*|Process a EVT_ENTER_WINDOW event.|
|*evt_leave_window() { | event | ... }*|Process a EVT_LEAVE_WINDOW event.|
|*evt_mousewheel() { | event | ... }*|Process a EVT_MOUSEWHEEL event.|
|*evt_mouse_events() { | event | ... }*|Process all mouse events.|
h2. Methods
* "MouseEvent#m__alt_down":#MouseEvent_maltdown
* "MouseEvent#m__control_down":#MouseEvent_mcontroldown
* "MouseEvent#m__left_down":#MouseEvent_mleftdown
* "MouseEvent#m__middle_down":#MouseEvent_mmiddledown
* "MouseEvent#m__right_down":#MouseEvent_mrightdown
* "MouseEvent#m__meta_down":#MouseEvent_mmetadown
* "MouseEvent#m__shift_down":#MouseEvent_mshiftdown
* "MouseEvent#m__x":#MouseEvent_mx
* "MouseEvent#m__y":#MouseEvent_my
* "MouseEvent#m__wheel_rotation":#MouseEvent_mwheelrotation
* "MouseEvent#m__wheel_delta":#MouseEvent_mwheeldelta
* "MouseEvent#m__lines_per_action":#MouseEvent_mlinesperaction
* "MouseEvent.new":#MouseEvent_new
* "MouseEvent#alt_down":#MouseEvent_altdown
* "MouseEvent#button":#MouseEvent_button
* "MouseEvent#button_dclick":#MouseEvent_buttondclick
* "MouseEvent#button_down":#MouseEvent_buttondown
* "MouseEvent#button_up":#MouseEvent_buttonup
* "MouseEvent#cmd_down":#MouseEvent_cmddown
* "MouseEvent#control_down":#MouseEvent_controldown
* "MouseEvent#dragging":#MouseEvent_dragging
* "MouseEvent#entering":#MouseEvent_entering
* "MouseEvent#get_button":#MouseEvent_getbutton
* "MouseEvent#get_position":#MouseEvent_getposition
* "MouseEvent#get_logical_position":#MouseEvent_getlogicalposition
* "MouseEvent#get_lines_per_action":#MouseEvent_getlinesperaction
* "MouseEvent#get_wheel_rotation":#MouseEvent_getwheelrotation
* "MouseEvent#get_wheel_delta":#MouseEvent_getwheeldelta
* "MouseEvent#get_x":#MouseEvent_getx
* "MouseEvent#get_y":#MouseEvent_gety
* "MouseEvent#is_button":#MouseEvent_isbutton
* "MouseEvent#is_page_scroll":#MouseEvent_ispagescroll
* "MouseEvent#leaving":#MouseEvent_leaving
* "MouseEvent#left_dclick":#MouseEvent_leftdclick
* "MouseEvent#left_down":#MouseEvent_leftdown
* "MouseEvent#left_is_down":#MouseEvent_leftisdown
* "MouseEvent#left_up":#MouseEvent_leftup
* "MouseEvent#meta_down":#MouseEvent_metadown
* "MouseEvent#middle_dclick":#MouseEvent_middledclick
* "MouseEvent#middle_down":#MouseEvent_middledown
* "MouseEvent#middle_is_down":#MouseEvent_middleisdown
* "MouseEvent#middle_up":#MouseEvent_middleup
* "MouseEvent#moving":#MouseEvent_moving
* "MouseEvent#right_dclick":#MouseEvent_rightdclick
* "MouseEvent#right_down":#MouseEvent_rightdown
* "MouseEvent#right_is_down":#MouseEvent_rightisdown
* "MouseEvent#right_up":#MouseEvent_rightup
* "MouseEvent#shift_down":#MouseEvent_shiftdown
h3(#MouseEvent_maltdown). MouseEvent#m__alt_down
boolm_altDown
true if the Alt key is pressed down.
h3(#MouseEvent_mcontroldown). MouseEvent#m__control_down
boolm_controlDown
true if control key is pressed down.
h3(#MouseEvent_mleftdown). MouseEvent#m__left_down
boolm_leftDown
true if the left mouse button is currently pressed down.
h3(#MouseEvent_mmiddledown). MouseEvent#m__middle_down
boolm_middleDown
true if the middle mouse button is currently pressed down.
h3(#MouseEvent_mrightdown). MouseEvent#m__right_down
boolm_rightDown
true if the right mouse button is currently pressed down.
h3(#MouseEvent_mmetadown). MouseEvent#m__meta_down
boolm_metaDown
true if the Meta key is pressed down.
h3(#MouseEvent_mshiftdown). MouseEvent#m__shift_down
boolm_shiftDown
true if shift is pressed down.
h3(#MouseEvent_mx). MouseEvent#m__x
longm_x
X-coordinate of the event.
h3(#MouseEvent_my). MouseEvent#m__y
longm_y
Y-coordinate of the event.
h3(#MouseEvent_mwheelrotation). MouseEvent#m__wheel_rotation
intm_wheelRotation
The distance the mouse wheel is rotated.
h3(#MouseEvent_mwheeldelta). MouseEvent#m__wheel_delta
intm_wheelDelta
The wheel delta, normally $120$.
h3(#MouseEvent_mlinesperaction). MouseEvent#m__lines_per_action
intm_linesPerAction
The configured number of lines (or whatever) to be scrolled per wheel
action.
h3(#MouseEvent_new). MouseEvent.new
*MouseEvent.new*(%(arg-type)"TYPE":type.html% mouseEventType = 0)
Constructor. Valid event types are:
* *EVT_ENTER_WINDOW*
* *EVT_LEAVE_WINDOW*
* *EVT_LEFT_DOWN*
* *EVT_LEFT_UP*
* *EVT_LEFT_DCLICK*
* *EVT_MIDDLE_DOWN*
* *EVT_MIDDLE_UP*
* *EVT_MIDDLE_DCLICK*
* *EVT_RIGHT_DOWN*
* *EVT_RIGHT_UP*
* *EVT_RIGHT_DCLICK*
* *EVT_MOTION*
* *EVT_MOUSEWHEEL*
h3(#MouseEvent_altdown). MouseEvent#alt_down
Boolean *alt_down*()
Returns true if the Alt key was down at the time of the event.
h3(#MouseEvent_button). MouseEvent#button
Boolean *button*(%(arg-type)Integer% button)
Returns true if the identified mouse button is changing state. Valid
values of _button_ are:
|@MOUSE_BTN_LEFT@|check if left button was pressed|
|@MOUSE_BTN_MIDDLE@|check if middle button was pressed|
|@MOUSE_BTN_RIGHT@|check if right button was pressed|
|@MOUSE_BTN_ANY@|check if any button was pressed|
h3(#MouseEvent_buttondclick). MouseEvent#button_dclick
Boolean *button_dclick*(%(arg-type)Integer% but = MOUSE_BTN_ANY)
If the argument is omitted, this returns true if the event was a mouse
double click event. Otherwise the argument specifies which double click event
was generated (see "Button":mouseeventbutton.html for the possible
values).
h3(#MouseEvent_buttondown). MouseEvent#button_down
Boolean *button_down*(%(arg-type)Integer% but = -1)
If the argument is omitted, this returns true if the event was a mouse
button down event. Otherwise the argument specifies which button-down event
was generated (see "Button":mouseeventbutton.html for the possible
values).
h3(#MouseEvent_buttonup). MouseEvent#button_up
Boolean *button_up*(%(arg-type)Integer% but = -1)
If the argument is omitted, this returns true if the event was a mouse
button up event. Otherwise the argument specifies which button-up event
was generated (see "Button":mouseeventbutton.html for the possible
values).
h3(#MouseEvent_cmddown). MouseEvent#cmd_down
Boolean *cmd_down*()
Same as "meta_down":#MouseEvent_metadown under Mac, same as
"control_down":#MouseEvent_controldown elsewhere.
h4. See also
"KeyEvent#cmd_down":keyevent.html#KeyEvent_cmddown
h3(#MouseEvent_controldown). MouseEvent#control_down
Boolean *control_down*()
Returns true if the control key was down at the time of the event.
h3(#MouseEvent_dragging). MouseEvent#dragging
Boolean *dragging*()
Returns true if this was a dragging event (motion while a button is depressed).
h4. See also
"Moving":mouseeventmoving.html
h3(#MouseEvent_entering). MouseEvent#entering
Boolean *entering*()
Returns true if the mouse was entering the window.
See also "MouseEvent#leaving":mouseevent.html#MouseEvent_leaving.
h3(#MouseEvent_getbutton). MouseEvent#get_button
Integer *get_button*()
Returns the mouse button which generated this event or @MOUSE_BTN_NONE@
if no button is involved (for mouse move, enter or leave event, for example).
Otherwise @MOUSE_BTN_LEFT@ is returned for the left button down, up and
double click events, @MOUSE_BTN_MIDDLE@ and @MOUSE_BTN_RIGHT@
for the same events for the middle and the right buttons respectively.
h3(#MouseEvent_getposition). MouseEvent#get_position
"Point":point.html *get_position*()
*get_position*(%(arg-type)Integer% x, %(arg-type)Integer% y)
*get_position*(%(arg-type)Integer% x, %(arg-type)Integer% y)
Sets *x and *y to the position at which the event occurred.
Returns the physical mouse position in pixels.
Note that if the mouse event has been artificially generated from a special
keyboard combination (e.g. under Windows when the ``menu'' key is pressed), the
returned position is @DefaultPosition@.
h3(#MouseEvent_getlogicalposition). MouseEvent#get_logical_position
"Point":point.html *get_logical_position*(%(arg-type)"DC":dc.html% dc)
Returns the logical mouse position in pixels (i.e. translated according to the
translation set for the DC, which usually indicates that the window has been scrolled).
h3(#MouseEvent_getlinesperaction). MouseEvent#get_lines_per_action
Integer *get_lines_per_action*()
Returns the configured number of lines (or whatever) to be scrolled per
wheel action. Defaults to three.
h3(#MouseEvent_getwheelrotation). MouseEvent#get_wheel_rotation
Integer *get_wheel_rotation*()
Get wheel rotation, positive or negative indicates direction of
rotation. Current devices all send an event when rotation is equal to
+/-WheelDelta, but this allows for finer resolution devices to be
created in the future. Because of this you shouldn't assume that one
event is equal to 1 line or whatever, but you should be able to either
do partial line scrolling or wait until +/-WheelDelta rotation values
have been accumulated before scrolling.
h3(#MouseEvent_getwheeldelta). MouseEvent#get_wheel_delta
Integer *get_wheel_delta*()
Get wheel delta, normally $120$. This is the threshold for action to be
taken, and one such action (for example, scrolling one increment)
should occur for each delta.
h3(#MouseEvent_getx). MouseEvent#get_x
Integer *get_x*()
Returns X coordinate of the physical mouse event position.
h3(#MouseEvent_gety). MouseEvent#get_y
Integer *get_y*()
Returns Y coordinate of the physical mouse event position.
h3(#MouseEvent_isbutton). MouseEvent#is_button
Boolean *is_button*()
Returns true if the event was a mouse button event (not necessarily a button down event -
that may be tested using _ButtonDown_).
h3(#MouseEvent_ispagescroll). MouseEvent#is_page_scroll
Boolean *is_page_scroll*()
Returns true if the system has been setup to do page scrolling with
the mouse wheel instead of line scrolling.
h3(#MouseEvent_leaving). MouseEvent#leaving
Boolean *leaving*()
Returns true if the mouse was leaving the window.
See also "MouseEvent#entering":mouseevent.html#MouseEvent_entering.
h3(#MouseEvent_leftdclick). MouseEvent#left_dclick
Boolean *left_dclick*()
Returns true if the event was a left double click.
h3(#MouseEvent_leftdown). MouseEvent#left_down
Boolean *left_down*()
Returns true if the left mouse button changed to down.
h3(#MouseEvent_leftisdown). MouseEvent#left_is_down
Boolean *left_is_down*()
Returns true if the left mouse button is currently down, independent
of the current event type.
Please notice that it is *not* the same as
"left_down":#MouseEvent_leftdown which returns true if the left mouse
button was just pressed. Rather, it describes the state of the mouse button
before the event happened.
This event is usually used in the mouse event handlers which process "move
mouse" messages to determine whether the user is (still) dragging the mouse.
h3(#MouseEvent_leftup). MouseEvent#left_up
Boolean *left_up*()
Returns true if the left mouse button changed to up.
h3(#MouseEvent_metadown). MouseEvent#meta_down
Boolean *meta_down*()
Returns true if the Meta key was down at the time of the event.
h3(#MouseEvent_middledclick). MouseEvent#middle_dclick
Boolean *middle_dclick*()
Returns true if the event was a middle double click.
h3(#MouseEvent_middledown). MouseEvent#middle_down
Boolean *middle_down*()
Returns true if the middle mouse button changed to down.
h3(#MouseEvent_middleisdown). MouseEvent#middle_is_down
Boolean *middle_is_down*()
Returns true if the middle mouse button is currently down, independent
of the current event type.
h3(#MouseEvent_middleup). MouseEvent#middle_up
Boolean *middle_up*()
Returns true if the middle mouse button changed to up.
h3(#MouseEvent_moving). MouseEvent#moving
Boolean *moving*()
Returns true if this was a motion event and no mouse buttons were pressed.
If any mouse button is held pressed, then this method returns and
"Dragging":mouseeventdragging.html returns .
h3(#MouseEvent_rightdclick). MouseEvent#right_dclick
Boolean *right_dclick*()
Returns true if the event was a right double click.
h3(#MouseEvent_rightdown). MouseEvent#right_down
Boolean *right_down*()
Returns true if the right mouse button changed to down.
h3(#MouseEvent_rightisdown). MouseEvent#right_is_down
Boolean *right_is_down*()
Returns true if the right mouse button is currently down, independent
of the current event type.
h3(#MouseEvent_rightup). MouseEvent#right_up
Boolean *right_up*()
Returns true if the right mouse button changed to up.
h3(#MouseEvent_shiftdown). MouseEvent#shift_down
Boolean *shift_down*()
Returns true if the shift key was down at the time of the event.