## wxMouseEvent

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 1 for the left mouse button, 2 for the middle one and 3 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 mouse enter and leave events are not natively supported by the system but are generated by wxWindows 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 LeftDown and LeftIsDown: the format 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 LeftDown returns `TRUE`, LeftIsDown will also return `TRUE` in wxWindows whatever the underlying GUI behaviour is (which is platform-dependent). The same applies, of course, to other mouse buttons as well.

Derived from

wxEvent

Include files

<wx/event.h>

Event table macros

To process a mouse event, use these event handler macros to direct input to member functions that take a wxMouseEvent argument.

EVT_LEFT_DOWN(func) | Process a wxEVT_LEFT_DOWN event.
EVT_LEFT_UP(func) | Process a wxEVT_LEFT_UP event.
EVT_LEFT_DCLICK(func) | Process a wxEVT_LEFT_DCLICK event.
EVT_MIDDLE_DOWN(func) | Process a wxEVT_MIDDLE_DOWN event.
EVT_MIDDLE_UP(func) | Process a wxEVT_MIDDLE_UP event.
EVT_MIDDLE_DCLICK(func) | Process a wxEVT_MIDDLE_DCLICK event.
EVT_RIGHT_DOWN(func) | Process a wxEVT_RIGHT_DOWN event.
EVT_RIGHT_UP(func) | Process a wxEVT_RIGHT_UP event.
EVT_RIGHT_DCLICK(func) | Process a wxEVT_RIGHT_DCLICK event.
EVT_MOTION(func) | Process a wxEVT_MOTION event.
EVT_ENTER_WINDOW(func) | Process a wxEVT_ENTER_WINDOW event.
EVT_LEAVE_WINDOW(func) | Process a wxEVT_LEAVE_WINDOW event.
EVT_MOUSEWHEEL(func) | Process a wxEVT_MOUSEWHEEL event.
EVT_MOUSE_EVENTS(func) | Process all mouse events.

Members

wxMouseEvent::m_altDown
wxMouseEvent::m_controlDown
wxMouseEvent::m_leftDown
wxMouseEvent::m_middleDown
wxMouseEvent::m_rightDown
wxMouseEvent::m_metaDown
wxMouseEvent::m_shiftDown
wxMouseEvent::m_x
wxMouseEvent::m_y
wxMouseEvent::m_wheelRotation
wxMouseEvent::m_wheelDelta
wxMouseEvent::m_linesPerAction
wxMouseEvent::wxMouseEvent
wxMouseEvent::AltDown
wxMouseEvent::Button
wxMouseEvent::ButtonDClick
wxMouseEvent::ButtonDown
wxMouseEvent::ButtonUp
wxMouseEvent::ControlDown
wxMouseEvent::Dragging
wxMouseEvent::Entering
wxMouseEvent::GetButton
wxMouseEvent::GetPosition
wxMouseEvent::GetLogicalPosition
wxMouseEvent::GetLinesPerAction
wxMouseEvent::GetWheelRotation
wxMouseEvent::GetWheelDelta
wxMouseEvent::GetX
wxMouseEvent::GetY
wxMouseEvent::IsButton
wxMouseEvent::IsPageScroll
wxMouseEvent::Leaving
wxMouseEvent::LeftDClick
wxMouseEvent::LeftDown
wxMouseEvent::LeftIsDown
wxMouseEvent::LeftUp
wxMouseEvent::MetaDown
wxMouseEvent::MiddleDClick
wxMouseEvent::MiddleDown
wxMouseEvent::MiddleIsDown
wxMouseEvent::MiddleUp
wxMouseEvent::Moving
wxMouseEvent::RightDClick
wxMouseEvent::RightDown
wxMouseEvent::RightIsDown
wxMouseEvent::RightUp
wxMouseEvent::ShiftDown

### wxMouseEvent::m_altDown

bool m_altDown

TRUE if the Alt key is pressed down.

### wxMouseEvent::m_controlDown

bool m_controlDown

TRUE if control key is pressed down.

### wxMouseEvent::m_leftDown

bool m_leftDown

TRUE if the left mouse button is currently pressed down.

### wxMouseEvent::m_middleDown

bool m_middleDown

TRUE if the middle mouse button is currently pressed down.

### wxMouseEvent::m_rightDown

bool m_rightDown

TRUE if the right mouse button is currently pressed down.

### wxMouseEvent::m_metaDown

bool m_metaDown

TRUE if the Meta key is pressed down.

### wxMouseEvent::m_shiftDown

bool m_shiftDown

TRUE if shift is pressed down.

### wxMouseEvent::m_x

long m_x

X-coordinate of the event.

### wxMouseEvent::m_y

long m_y

Y-coordinate of the event.

### wxMouseEvent::m_wheelRotation

int m_wheelRotation

The distance the mouse wheel is rotated.

### wxMouseEvent::m_wheelDelta

int m_wheelDelta

The wheel delta, normally 120.

### wxMouseEvent::m_linesPerAction

int m_linesPerAction

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

### wxMouseEvent::wxMouseEvent

wxMouseEvent(WXTYPE mouseEventType = 0, int id = 0)

Constructor. Valid event types are:

- wxEVT_ENTER_WINDOW
- wxEVT_LEAVE_WINDOW
- wxEVT_LEFT_DOWN
- wxEVT_LEFT_UP
- wxEVT_LEFT_DCLICK
- wxEVT_MIDDLE_DOWN
- wxEVT_MIDDLE_UP
- wxEVT_MIDDLE_DCLICK
- wxEVT_RIGHT_DOWN
- wxEVT_RIGHT_UP
- wxEVT_RIGHT_DCLICK
- wxEVT_MOTION
- wxEVT_MOUSEWHEEL

### wxMouseEvent::AltDown

bool AltDown()

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

### wxMouseEvent::Button

bool Button(int button)

Returns TRUE if the identified mouse button is changing state. Valid values of button are 1, 2 or 3 for left, middle and right buttons respectively.

### wxMouseEvent::ButtonDClick

bool ButtonDClick(int but = -1)

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 (1, 2 or 3 for left, middle and right buttons respectively).

### wxMouseEvent::ButtonDown

bool ButtonDown(int 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 (1, 2 or 3 for left, middle and right buttons respectively).

### wxMouseEvent::ButtonUp

bool ButtonUp(int 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 (1, 2 or 3 for left, middle and right buttons respectively).

### wxMouseEvent::ControlDown

bool ControlDown()

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

### wxMouseEvent::Dragging

bool Dragging()

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

### wxMouseEvent::Entering

bool Entering()

Returns TRUE if the mouse was entering the window.

See also wxMouseEvent::Leaving.

### wxMouseEvent::GetButton

int GetButton() const

Returns the mouse button which generated this event or -1 if no button is involved (for mouse move, enter or leave event, for example). The value 1 is returned for the left button down, up and double click events, 2 and 3 for the same events for the middle and the right buttons respectively.

### wxMouseEvent::GetPosition

wxPoint GetPosition() const

void GetPosition(wxCoord* x, wxCoord* y) const

void GetPosition(long* x, long* y) const

Sets *x and *y to the position at which the event occurred.

Returns the physical mouse position in pixels.

### wxMouseEvent::GetLogicalPosition

wxPoint GetLogicalPosition(const wxDC& dc) const

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

### wxMouseEvent::GetLinesPerAction

int GetLinesPerAction() const

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

### wxMouseEvent::GetWheelRotation

int GetWheelRotation() const

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.

### wxMouseEvent::GetWheelDelta

int GetWheelDelta() const

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.

### wxMouseEvent::GetX

long GetX() const

Returns X coordinate of the physical mouse event position.

### wxMouseEvent::GetY

long GetY()

Returns Y coordinate of the physical mouse event position.

### wxMouseEvent::IsButton

bool IsButton() const

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

### wxMouseEvent::IsPageScroll

bool IsPageScroll() const

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

### wxMouseEvent::Leaving

bool Leaving() const

Returns TRUE if the mouse was leaving the window.

See also wxMouseEvent::Entering.

### wxMouseEvent::LeftDClick

bool LeftDClick() const

Returns TRUE if the event was a left double click.

### wxMouseEvent::LeftDown

bool LeftDown() const

Returns TRUE if the left mouse button changed to down.

### wxMouseEvent::LeftIsDown

bool LeftIsDown() const

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

### wxMouseEvent::LeftUp

bool LeftUp() const

Returns TRUE if the left mouse button changed to up.

### wxMouseEvent::MetaDown

bool MetaDown() const

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

### wxMouseEvent::MiddleDClick

bool MiddleDClick() const

Returns TRUE if the event was a middle double click.

### wxMouseEvent::MiddleDown

bool MiddleDown() const

Returns TRUE if the middle mouse button changed to down.

### wxMouseEvent::MiddleIsDown

bool MiddleIsDown() const

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

### wxMouseEvent::MiddleUp

bool MiddleUp() const

Returns TRUE if the middle mouse button changed to up.

### wxMouseEvent::Moving

bool Moving() const

Returns TRUE if this was a motion event (no buttons depressed).

### wxMouseEvent::RightDClick

bool RightDClick() const

Returns TRUE if the event was a right double click.

### wxMouseEvent::RightDown

bool RightDown() const

Returns TRUE if the right mouse button changed to down.

### wxMouseEvent::RightIsDown

bool RightIsDown() const

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

### wxMouseEvent::RightUp

bool RightUp() const

Returns TRUE if the right mouse button changed to up.

### wxMouseEvent::ShiftDown

bool ShiftDown() const

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