Class: Wx::MouseEvent

Inherits:
Event show all
Defined in:
lib/wx/doc/gen/events.rb

Overview

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 Wx::MouseButton::MOUSE_BTN_LEFT for the left mouse button, Wx::MouseButton::MOUSE_BTN_MIDDLE for the middle one and Wx::MouseButton::MOUSE_BTN_RIGHT for the right one. And if the system supports more buttons, the Wx::MouseButton::MOUSE_BTN_AUX1 and Wx::MouseButton::MOUSE_BTN_AUX2 events can also be generated. Note that not all mice have even a middle button so a portable application should avoid relying on the events from it (but the right button click can be emulated using the left mouse button with the control key under Mac platforms with a single button mouse). For the EVT_ENTER_WINDOW and EVT_LEAVE_WINDOW events purposes, the mouse is considered to be inside the window if it is in the window client area and not inside one of its children. In other words, the parent window receives EVT_LEAVE_WINDOW event not only when the mouse leaves the window entirely but also when it enters one of its children. The position associated with a mouse event is expressed in the window coordinates of the window which generated the event, you can use Window#client_to_screen to convert it to screen coordinates and possibly call Window#screen_to_client next to convert it to window coordinates of another window.

Note:

Note the difference between methods like #left_down and the inherited Wx::MouseState#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 LeftIsDown to test whether the left mouse button is (still) depressed. Also, by convention, if #left_down returns true, LeftIsDown will also return true in wxWidgets whatever the underlying GUI behaviour is (which is platform-dependent). The same applies, of course, to other mouse buttons as well.

Events using this class

The following event-handler methods redirect the events to member method or handler blocks for MouseEvent events. Event handler methods:

Category: Events

See Also:

Instance Method Summary collapse

Methods inherited from Event

#clone, #get_event_category, #get_event_object, #get_event_type, #get_id, #get_skipped, #get_timestamp, #is_command_event, #resume_propagation, #set_event_object, #set_event_type, #set_id, #set_timestamp, #should_propagate, #skip, #stop_propagation

Methods inherited from Object

#clone, #dup, #is_same_as, #un_share

Constructor Details

#initialize(mouseEventType = Wx::EVT_NULL) ⇒ Wx::MouseEvent

Parameters:

  • mouseEventType (Wx::GenericCollapsiblePane::EventType) (defaults to: Wx::EVT_NULL)


382
# File 'lib/wx/doc/gen/events.rb', line 382

def initialize(mouseEventType=Wx::EVT_NULL) end

Instance Method Details

#alt_downBoolean

Returns true if the Alt key is pressed.

Notice that #get_modifiers should usually be used instead of this one.

Returns:

  • (Boolean)


738
# File 'lib/wx/doc/gen/events.rb', line 738

def alt_down; end

#aux1d_clickBoolean

Returns true if the event was a first extra button double click.

Returns:

  • (Boolean)


386
# File 'lib/wx/doc/gen/events.rb', line 386

def aux1d_click; end

#aux1downBoolean

Returns true if the first extra button mouse button changed to down.

Returns:

  • (Boolean)


390
# File 'lib/wx/doc/gen/events.rb', line 390

def aux1down; end

#aux1is_downBoolean

Returns true if the first extra button mouse button is currently down.

Returns:

  • (Boolean)


624
# File 'lib/wx/doc/gen/events.rb', line 624

def aux1is_down; end

#aux1upBoolean

Returns true if the first extra button mouse button changed to up.

Returns:

  • (Boolean)


394
# File 'lib/wx/doc/gen/events.rb', line 394

def aux1up; end

#aux2d_clickBoolean

Returns true if the event was a second extra button double click.

Returns:

  • (Boolean)


398
# File 'lib/wx/doc/gen/events.rb', line 398

def aux2d_click; end

#aux2downBoolean

Returns true if the second extra button mouse button changed to down.

Returns:

  • (Boolean)


402
# File 'lib/wx/doc/gen/events.rb', line 402

def aux2down; end

#aux2is_downBoolean

Returns true if the second extra button mouse button is currently down.

Returns:

  • (Boolean)


628
# File 'lib/wx/doc/gen/events.rb', line 628

def aux2is_down; end

#aux2upBoolean

Returns true if the second extra button mouse button changed to up.

Returns:

  • (Boolean)


406
# File 'lib/wx/doc/gen/events.rb', line 406

def aux2up; end

#button(but) ⇒ Boolean

Returns true if the event was generated by the specified button.

Parameters:

Returns:

  • (Boolean)

See Also:

  • Wx::MouseEvent.wxMouseStatewxMouseState::ButtoinIsDown()


414
# File 'lib/wx/doc/gen/events.rb', line 414

def button(but) end

#button_d_click(but = Wx::MouseButton::MOUSE_BTN_ANY) ⇒ Boolean

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

Parameters:

Returns:

  • (Boolean)


421
# File 'lib/wx/doc/gen/events.rb', line 421

def button_d_click(but=Wx::MouseButton::MOUSE_BTN_ANY) end

#button_down(but = Wx::MouseButton::MOUSE_BTN_ANY) ⇒ Boolean

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

Parameters:

Returns:

  • (Boolean)


428
# File 'lib/wx/doc/gen/events.rb', line 428

def button_down(but=Wx::MouseButton::MOUSE_BTN_ANY) end

#button_up(but = Wx::MouseButton::MOUSE_BTN_ANY) ⇒ Boolean

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

Parameters:

Returns:

  • (Boolean)


435
# File 'lib/wx/doc/gen/events.rb', line 435

def button_up(but=Wx::MouseButton::MOUSE_BTN_ANY) end

#cmd_downBoolean

Returns true if the key used for command accelerators is pressed.

Same as #control_down. Deprecated. Notice that #get_modifiers should usually be used instead of this one.

Returns:

  • (Boolean)


745
# File 'lib/wx/doc/gen/events.rb', line 745

def cmd_down; end

#control_downBoolean

Returns true if the Control key or Apple/Command key under macOS is pressed.

This function doesn’t distinguish between right and left control keys. Notice that #get_modifiers should usually be used instead of this one.

Returns:

  • (Boolean)


718
# File 'lib/wx/doc/gen/events.rb', line 718

def control_down; end

#draggingBoolean

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

Returns:

  • (Boolean)

See Also:



442
# File 'lib/wx/doc/gen/events.rb', line 442

def dragging; end

#enteringBoolean

Returns true if the mouse was entering the window.

Returns:

  • (Boolean)

See Also:



449
# File 'lib/wx/doc/gen/events.rb', line 449

def entering; end

#get_buttonInteger

Returns the mouse button which generated this event or Wx::MouseButton::MOUSE_BTN_NONE if no button is involved (for mouse move, enter or leave event, for example).

Otherwise Wx::MouseButton::MOUSE_BTN_LEFT is returned for the left button down, up and double click events, Wx::MouseButton::MOUSE_BTN_MIDDLE and Wx::MouseButton::MOUSE_BTN_RIGHT for the same events for the middle and the right buttons respectively.

Returns:

  • (Integer)


455
# File 'lib/wx/doc/gen/events.rb', line 455

def get_button; end

#get_click_countInteger Also known as: click_count

Returns the number of mouse clicks for this event: 1 for a simple click, 2 for a double-click, 3 for a triple-click and so on.

Currently this function is implemented only in WXOSX and returns -1 for the other platforms (you can still distinguish simple clicks from double-clicks as they generate different kinds of events however).

Returns:

  • (Integer)


461
# File 'lib/wx/doc/gen/events.rb', line 461

def get_click_count; end

#get_columns_per_actionInteger Also known as: columns_per_action

Returns the configured number of columns (or whatever) to be scrolled per wheel action.

Default value under most platforms is three.

Returns:

  • (Integer)

See Also:



477
# File 'lib/wx/doc/gen/events.rb', line 477

def get_columns_per_action; end

#get_lines_per_actionInteger Also known as: lines_per_action

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

Default value under most platforms is three.

Returns:

  • (Integer)

See Also:



469
# File 'lib/wx/doc/gen/events.rb', line 469

def get_lines_per_action; end

#get_logical_position(dc) ⇒ Wx::Point Also known as: logical_position

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

Parameters:

Returns:



483
# File 'lib/wx/doc/gen/events.rb', line 483

def get_logical_position(dc) end

#get_magnificationFloat Also known as: magnification

For magnify (pinch to zoom) events: returns the change in magnification.

A value of 0 means no change, a positive value means we should enlarge (or zoom in), a negative value means we should shrink (or zoom out). This method is only valid to call for EVT_MAGNIFY events which are currently only generated under macOS.

Returns:

  • (Float)

See Also:



492
# File 'lib/wx/doc/gen/events.rb', line 492

def get_magnification; end

#get_modifiersInteger Also known as: modifiers

Return the bit mask of all pressed modifier keys.

The return value is a combination of KeyModifier::MOD_ALT, KeyModifier::MOD_CONTROL, KeyModifier::MOD_SHIFT and KeyModifier::MOD_META bit masks. Additionally, KeyModifier::MOD_NONE is defined as 0, i.e. corresponds to no modifiers (see #has_any_modifiers) and KeyModifier::MOD_CMD is either KeyModifier::MOD_CONTROL (MSW and Unix) or KeyModifier::MOD_META (Mac), see #cmd_down. See KeyModifier for the full list of modifiers. Notice that this function is easier to use correctly than, for example, #control_down because when using the latter you also have to remember to test that none of the other modifiers is pressed:

if event.control_down && !event.alt_down && !event.shift_down && !event.meta_down
    # ... handle Ctrl-XXX ...

and forgetting to do it can result in serious program bugs (e.g. program not working with European keyboard layout where AltGr key which is seen by the program as combination of CTRL and ALT is used). On the other hand, you can simply write:

if event.get_modifiers == Wx::KeyModifier::MOD_CONTROL
    # ... handle Ctrl-XXX ...

with this function.

Returns:

  • (Integer)


694
# File 'lib/wx/doc/gen/events.rb', line 694

def get_modifiers; end

#get_positionWx::Point Also known as: position

Returns the physical mouse position.

Returns:



597
# File 'lib/wx/doc/gen/events.rb', line 597

def get_position; end

#get_wheel_axisWx::MouseWheelAxis Also known as: wheel_axis

Gets the axis the wheel operation concerns.

Usually the mouse wheel is used to scroll vertically so Wx::MouseWheelAxis::MOUSE_WHEEL_VERTICAL is returned but some mice (and most trackpads) also allow to use the wheel to scroll horizontally in which case Wx::MouseWheelAxis::MOUSE_WHEEL_HORIZONTAL is returned. Notice that before wxWidgets 2.9.4 this method returned int.

Returns:



522
# File 'lib/wx/doc/gen/events.rb', line 522

def get_wheel_axis; end

#get_wheel_deltaInteger Also known as: 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.

Returns:

  • (Integer)


499
# File 'lib/wx/doc/gen/events.rb', line 499

def get_wheel_delta; end

#get_wheel_rotationInteger Also known as: wheel_rotation

Get wheel rotation, positive or negative indicates direction of rotation.

Current devices all send an event when rotation is at least +/-WheelDelta, but finer resolution devices can be created in the future. Because of this you shouldn’t assume that one event is equal to 1 line, but you should be able to either do partial line scrolling or wait until several events accumulate before scrolling.

Returns:

  • (Integer)


514
# File 'lib/wx/doc/gen/events.rb', line 514

def get_wheel_rotation; end

#get_xInteger Also known as: x

Returns X coordinate of the physical mouse event position.

Returns:

  • (Integer)


602
# File 'lib/wx/doc/gen/events.rb', line 602

def get_x; end

#get_yInteger Also known as: y

Returns Y coordinate of the physical mouse event position.

Returns:

  • (Integer)


607
# File 'lib/wx/doc/gen/events.rb', line 607

def get_y; end

#has_any_modifiersBoolean Also known as: has_any_modifiers?

Returns true if any modifiers at all are pressed.

This is equivalent to get_modifiers != KeyModifier::MOD_NONE. Notice that this is different from #has_modifiers method which doesn’t take e.g. Shift modifier into account. This method is most suitable for mouse events when any modifier, including Shift, can change the interpretation of the event.

Returns:

  • (Boolean)


702
# File 'lib/wx/doc/gen/events.rb', line 702

def has_any_modifiers; end

#has_modifiersBoolean Also known as: has_modifiers?

Returns true if Control or Alt are pressed.

Checks if Control, Alt or, under macOS only, Command key are pressed (notice that the real Control key is still taken into account under OS X too). This method returns false if only Shift is pressed for compatibility reasons and also because pressing Shift usually doesn’t change the interpretation of key events, see #has_any_modifiers if you want to take Shift into account as well.

Returns:

  • (Boolean)


710
# File 'lib/wx/doc/gen/events.rb', line 710

def has_modifiers; end

#is_buttonBoolean Also known as: button?

Returns true if the event was a mouse button event (not necessarily a button down event - that may be tested using #button_down).

Returns:

  • (Boolean)


527
# File 'lib/wx/doc/gen/events.rb', line 527

def is_button; end

#is_page_scrollBoolean Also known as: page_scroll?

Returns true if the system has been setup to do page scrolling with the mouse wheel instead of line scrolling.

Returns:

  • (Boolean)


532
# File 'lib/wx/doc/gen/events.rb', line 532

def is_page_scroll; end

#is_wheel_invertedBoolean Also known as: wheel_inverted?

On Mac, has the user selected “Natural” scrolling in their System Preferences? Currently false on all other OS’s.

“Natural” scrolling means that content scrolling happens in the opposite direction, and if you are indeed scrolling content then you don’t need to use this function because macOS has already inverted the scroll direction. But there can be special situations where you want the mouse wheel action to work always in the same direction and in that case you will need this function.

Returns:

  • (Boolean)


506
# File 'lib/wx/doc/gen/events.rb', line 506

def is_wheel_inverted; end

#leavingBoolean

Returns true if the mouse was leaving the window.

Returns:

  • (Boolean)

See Also:



540
# File 'lib/wx/doc/gen/events.rb', line 540

def leaving; end

#left_d_clickBoolean

Returns true if the event was a left double click.

Returns:

  • (Boolean)


544
# File 'lib/wx/doc/gen/events.rb', line 544

def left_d_click; end

#left_downBoolean

Returns true if the left mouse button changed to down.

Returns:

  • (Boolean)


548
# File 'lib/wx/doc/gen/events.rb', line 548

def left_down; end

#left_is_downBoolean

Returns true if the left mouse button is currently down.

Returns:

  • (Boolean)


612
# File 'lib/wx/doc/gen/events.rb', line 612

def left_is_down; end

#left_upBoolean

Returns true if the left mouse button changed to up.

Returns:

  • (Boolean)


552
# File 'lib/wx/doc/gen/events.rb', line 552

def left_up; end

#magnifyBoolean

Returns true if the event is a magnify (i.e. pinch to zoom) event.

Such events are currently generated only under macOS.

Returns:

  • (Boolean)

See Also:



559
# File 'lib/wx/doc/gen/events.rb', line 559

def magnify; end

#meta_downBoolean

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

Returns:

  • (Boolean)


563
# File 'lib/wx/doc/gen/events.rb', line 563

def meta_down; end

#middle_d_clickBoolean

Returns true if the event was a middle double click.

Returns:

  • (Boolean)


567
# File 'lib/wx/doc/gen/events.rb', line 567

def middle_d_click; end

#middle_downBoolean

Returns true if the middle mouse button changed to down.

Returns:

  • (Boolean)


571
# File 'lib/wx/doc/gen/events.rb', line 571

def middle_down; end

#middle_is_downBoolean

Returns true if the middle mouse button is currently down.

Returns:

  • (Boolean)


616
# File 'lib/wx/doc/gen/events.rb', line 616

def middle_is_down; end

#middle_upBoolean

Returns true if the middle mouse button changed to up.

Returns:

  • (Boolean)


575
# File 'lib/wx/doc/gen/events.rb', line 575

def middle_up; end

#movingBoolean

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 false and #dragging returns true.

Returns:

  • (Boolean)


581
# File 'lib/wx/doc/gen/events.rb', line 581

def moving; end

#raw_control_downBoolean

Returns true if the Control key (also under macOS).

This function doesn’t distinguish between right and left control keys. Notice that #get_modifiers should usually be used instead of this one.

Returns:

  • (Boolean)


725
# File 'lib/wx/doc/gen/events.rb', line 725

def raw_control_down; end

#right_d_clickBoolean

Returns true if the event was a right double click.

Returns:

  • (Boolean)


585
# File 'lib/wx/doc/gen/events.rb', line 585

def right_d_click; end

#right_downBoolean

Returns true if the right mouse button changed to down.

Returns:

  • (Boolean)


589
# File 'lib/wx/doc/gen/events.rb', line 589

def right_down; end

#right_is_downBoolean

Returns true if the right mouse button is currently down.

Returns:

  • (Boolean)


620
# File 'lib/wx/doc/gen/events.rb', line 620

def right_is_down; end

#right_upBoolean

Returns true if the right mouse button changed to up.

Returns:

  • (Boolean)


593
# File 'lib/wx/doc/gen/events.rb', line 593

def right_up; end

#set_alt_down(down) ⇒ void Also known as: alt_down=

This method returns an undefined value.

Parameters:

  • down (Boolean)


764
# File 'lib/wx/doc/gen/events.rb', line 764

def set_alt_down(down) end

#set_aux1down(down) ⇒ void Also known as: aux1down=

This method returns an undefined value.

Parameters:

  • down (Boolean)


662
# File 'lib/wx/doc/gen/events.rb', line 662

def set_aux1down(down) end

#set_aux2down(down) ⇒ void Also known as: aux2down=

This method returns an undefined value.

Parameters:

  • down (Boolean)


667
# File 'lib/wx/doc/gen/events.rb', line 667

def set_aux2down(down) end

#set_control_down(down) ⇒ void Also known as: control_down=

This method returns an undefined value.

Parameters:

  • down (Boolean)


749
# File 'lib/wx/doc/gen/events.rb', line 749

def set_control_down(down) end

#set_left_down(down) ⇒ void Also known as: left_down=

This method returns an undefined value.

Parameters:

  • down (Boolean)


647
# File 'lib/wx/doc/gen/events.rb', line 647

def set_left_down(down) end

#set_meta_down(down) ⇒ void Also known as: meta_down=

This method returns an undefined value.

Parameters:

  • down (Boolean)


769
# File 'lib/wx/doc/gen/events.rb', line 769

def set_meta_down(down) end

#set_middle_down(down) ⇒ void Also known as: middle_down=

This method returns an undefined value.

Parameters:

  • down (Boolean)


652
# File 'lib/wx/doc/gen/events.rb', line 652

def set_middle_down(down) end

#set_position(pos) ⇒ void Also known as: position=

This method returns an undefined value.

Parameters:



642
# File 'lib/wx/doc/gen/events.rb', line 642

def set_position(pos) end

#set_raw_control_down(down) ⇒ void Also known as: raw_control_down=

This method returns an undefined value.

Parameters:

  • down (Boolean)


754
# File 'lib/wx/doc/gen/events.rb', line 754

def set_raw_control_down(down) end

#set_right_down(down) ⇒ void Also known as: right_down=

This method returns an undefined value.

Parameters:

  • down (Boolean)


657
# File 'lib/wx/doc/gen/events.rb', line 657

def set_right_down(down) end

#set_shift_down(down) ⇒ void Also known as: shift_down=

This method returns an undefined value.

Parameters:

  • down (Boolean)


759
# File 'lib/wx/doc/gen/events.rb', line 759

def set_shift_down(down) end

#set_state(state) ⇒ void Also known as: state=

This method returns an undefined value.

Parameters:



672
# File 'lib/wx/doc/gen/events.rb', line 672

def set_state(state) end

#set_x(x) ⇒ void Also known as: x=

This method returns an undefined value.

Parameters:

  • x (Integer)


632
# File 'lib/wx/doc/gen/events.rb', line 632

def set_x(x) end

#set_y(y) ⇒ void Also known as: y=

This method returns an undefined value.

Parameters:

  • y (Integer)


637
# File 'lib/wx/doc/gen/events.rb', line 637

def set_y(y) end

#shift_downBoolean

Returns true if the Shift key is pressed.

This function doesn’t distinguish between right and left shift keys. Notice that #get_modifiers should usually be used instead of this one.

Returns:

  • (Boolean)


732
# File 'lib/wx/doc/gen/events.rb', line 732

def shift_down; end