wxRuby Documentation Home

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 and
left_is_down: 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 to test
whether the left mouse button is (still) depressed. Also, by convention, if
left_down returns true,
left_is_down 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.

Derived from

Event

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 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.

Methods

MouseEvent#m__alt_down

boolm_altDown

true if the Alt key is pressed down.

MouseEvent#m__control_down

boolm_controlDown

true if control key is pressed down.

MouseEvent#m__left_down

boolm_leftDown

true if the left mouse button is currently pressed down.

MouseEvent#m__middle_down

boolm_middleDown

true if the middle mouse button is currently pressed down.

MouseEvent#m__right_down

boolm_rightDown

true if the right mouse button is currently pressed down.

MouseEvent#m__meta_down

boolm_metaDown

true if the Meta key is pressed down.

MouseEvent#m__shift_down

boolm_shiftDown

true if shift is pressed down.

MouseEvent#m__x

longm_x

X-coordinate of the event.

MouseEvent#m__y

longm_y

Y-coordinate of the event.

MouseEvent#m__wheel_rotation

intm_wheelRotation

The distance the mouse wheel is rotated.

MouseEvent#m__wheel_delta

intm_wheelDelta

The wheel delta, normally $120$.

MouseEvent#m__lines_per_action

intm_linesPerAction

The configured number of lines (or whatever) to be scrolled per wheel
action.

MouseEvent.new

MouseEvent.new(%(arg-type)TYPE% mouseEventType = 0)

Constructor. Valid event types are:

MouseEvent#alt_down

Boolean alt_down()

Returns true if the Alt key was down at the time of the event.

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

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 for the possible
values).

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 for the possible
values).

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 for the possible
values).

MouseEvent#cmd_down

Boolean cmd_down()

Same as meta_down under Mac, same as
control_down elsewhere.

See also

KeyEvent#cmd_down

MouseEvent#control_down

Boolean control_down()

Returns true if the control key was down at the time of the event.

MouseEvent#dragging

Boolean dragging()

Returns true if this was a dragging event (motion while a button is depressed).

See also

Moving

MouseEvent#entering

Boolean entering()

Returns true if the mouse was entering the window.

See also MouseEvent#leaving.

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.

MouseEvent#get_position

Point get_position() get_position(%(arg-type)Integer% x, Integer y) get_position(%(arg-type)Integer% x, 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.

MouseEvent#get_logical_position

Point get_logical_position(%(arg-type)DC% 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).

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.

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.

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.

MouseEvent#get_x

Integer get_x()

Returns X coordinate of the physical mouse event position.

MouseEvent#get_y

Integer get_y()

Returns Y coordinate of the physical mouse event position.

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).

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.

MouseEvent#leaving

Boolean leaving()

Returns true if the mouse was leaving the window.

See also MouseEvent#entering.

MouseEvent#left_dclick

Boolean left_dclick()

Returns true if the event was a left double click.

MouseEvent#left_down

Boolean left_down()

Returns true if the left mouse button changed to down.

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 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.

MouseEvent#left_up

Boolean left_up()

Returns true if the left mouse button changed to up.

MouseEvent#meta_down

Boolean meta_down()

Returns true if the Meta key was down at the time of the event.

MouseEvent#middle_dclick

Boolean middle_dclick()

Returns true if the event was a middle double click.

MouseEvent#middle_down

Boolean middle_down()

Returns true if the middle mouse button changed to down.

MouseEvent#middle_is_down

Boolean middle_is_down()

Returns true if the middle mouse button is currently down, independent
of the current event type.

MouseEvent#middle_up

Boolean middle_up()

Returns true if the middle mouse button changed to up.

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 returns .

MouseEvent#right_dclick

Boolean right_dclick()

Returns true if the event was a right double click.

MouseEvent#right_down

Boolean right_down()

Returns true if the right mouse button changed to down.

MouseEvent#right_is_down

Boolean right_is_down()

Returns true if the right mouse button is currently down, independent
of the current event type.

MouseEvent#right_up

Boolean right_up()

Returns true if the right mouse button changed to up.

MouseEvent#shift_down

Boolean shift_down()

Returns true if the shift key was down at the time of the event.

[This page automatically generated from the Textile source at 2023-06-09 00:45:25 +0000]