This event class contains information about mouse events. See wxWindow::OnMouseEvent.
Derived from
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_MOUSE_EVENTS(func) | Process all mouse events. |
wxMouseEvent::m_altDown
wxMouseEvent::m_controlDown
wxMouseEvent::m_leftDown
wxMouseEvent::m_middleDown
wxMouseEvent::m_rightDown
wxMouseEvent::m_leftDown
wxMouseEvent::m_metaDown
wxMouseEvent::m_shiftDown
wxMouseEvent::m_x
wxMouseEvent::m_y
wxMouseEvent::wxMouseEvent
wxMouseEvent::AltDown
wxMouseEvent::Button
wxMouseEvent::ButtonDClick
wxMouseEvent::ButtonDown
wxMouseEvent::ButtonUp
wxMouseEvent::ControlDown
wxMouseEvent::Dragging
wxMouseEvent::Entering
wxMouseEvent::GetX
wxMouseEvent::GetY
wxMouseEvent::IsButton
wxMouseEvent::Leaving
wxMouseEvent::LeftDClick
wxMouseEvent::LeftDown
wxMouseEvent::LeftIsDown
wxMouseEvent::LeftUp
wxMouseEvent::MetaDown
wxMouseEvent::MiddleDClick
wxMouseEvent::MiddleDown
wxMouseEvent::MiddleIsDown
wxMouseEvent::MiddleUp
wxMouseEvent::Moving
wxMouseEvent::Position
wxMouseEvent::RightDClick
wxMouseEvent::RightDown
wxMouseEvent::RightIsDown
wxMouseEvent::RightUp
wxMouseEvent::ShiftDown
bool m_altDown
TRUE if the Alt key is pressed down.
bool m_controlDown
TRUE if control key is pressed down.
bool m_leftDown
TRUE if the left mouse button is currently pressed down.
bool m_middleDown
TRUE if the middle mouse button is currently pressed down.
bool m_rightDown
TRUE if the right mouse button is currently pressed down.
bool m_leftDown
TRUE if the left mouse button is currently pressed down.
bool m_metaDown
TRUE if the Meta key is pressed down.
bool m_shiftDown
TRUE if shift is pressed down.
float m_x
X-coordinate of the event.
float m_y
Y-coordinate of the event.
wxMouseEvent(WXTYPE mouseEventType = 0, int id = 0)
Constructor. Valid event types are:
bool AltDown()
Returns TRUE if the Alt key was down at the time of the event.
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.
Not all mice have middle buttons so a portable application should avoid this one.
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).
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).
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).
bool ControlDown()
Returns TRUE if the control key was down at the time of the event.
bool Dragging()
Returns TRUE if this was a dragging event (motion while a button is depressed).
bool Entering()
Returns TRUE if the mouse was entering the window (MS Windows and Motif).
See also wxMouseEvent::Leaving.
float GetX()
Returns X coordinate of the mouse event position.
float GetY()
Returns Y coordinate of the mouse event position.
bool IsButton()
Returns TRUE if the event was a mouse button event (not necessarily a button down event - that may be tested using ButtonDown).
bool Leaving()
Returns TRUE if the mouse was leaving the window (MS Windows and Motif).
See also wxMouseEvent::Entering.
bool LeftDClick()
Returns TRUE if the event was a left double click.
bool LeftDown()
Returns TRUE if the left mouse button changed to down.
bool LeftIsDown()
Returns TRUE if the left mouse button is currently down, independent of the current event type.
bool LeftUp()
Returns TRUE if the left mouse button changed to up.
bool MetaDown()
Returns TRUE if the Meta key was down at the time of the event.
bool MiddleDClick()
Returns TRUE if the event was a middle double click.
bool MiddleDown()
Returns TRUE if the middle mouse button changed to down.
bool MiddleIsDown()
Returns TRUE if the middle mouse button is currently down, independent of the current event type.
bool MiddleUp()
Returns TRUE if the middle mouse button changed to up.
bool Moving()
Returns TRUE if this was a motion event (no buttons depressed).
void Position(float *x, float *y)
Sets *x and *y to the position at which the event occurred. If the window is a window, the position is converted to logical units (according to the current mapping mode) with scrolling taken into account. To get back to device units (for example to calculate where on the screen to place a dialog box associated with a window mouse event), use wxDC::LogicalToDeviceX and wxDC::LogicalToDeviceY.
For example, the following code calculates screen pixel coordinates from the frame position, window view start (assuming the window is the only subwindow on the frame and therefore at the top left of it), and the logical event position. A menu is popped up at the position where the mouse click occurred. (Note that the application should also check that the dialog box will be visible on the screen, since the click could have occurred near the screen edge!)
float event_x, event_y; event.Position(&event_x, &event_y); frame->GetPosition(&x, &y); window->ViewStart(&x1, &y1); int mouse_x = (int)(window->GetDC()->LogicalToDeviceX(event_x + x - x1); int mouse_y = (int)(window->GetDC()->LogicalToDeviceY(event_y + y - y1); char *choice = wxGetSingleChoice("Menu", "Pick a node action", no_choices, choices, frame, mouse_x, mouse_y);
bool RightDClick()
Returns TRUE if the event was a right double click.
bool RightDown()
Returns TRUE if the right mouse button changed to down.
bool RightIsDown()
Returns TRUE if the right mouse button is currently down, independent of the current event type.
bool RightUp()
Returns TRUE if the right mouse button changed to up.
bool ShiftDown()
Returns TRUE if the shift key was down at the time of the event.