Contents Up Previous Next

wxMouseEvent

This event class contains information about mouse events. See wxWindow::OnMouseEvent.

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


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_leftDown

bool m_leftDown

TRUE if the left 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

float m_x

X-coordinate of the event.


wxMouseEvent::m_y

float m_y

Y-coordinate of the event.


wxMouseEvent::wxMouseEvent

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

Constructor. Valid event types are:


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.

Not all mice have middle buttons so a portable application should avoid this one.


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 (MS Windows and Motif).

See also wxMouseEvent::Leaving.


wxMouseEvent::GetX

float GetX()

Returns X coordinate of the mouse event position.


wxMouseEvent::GetY

float GetY()

Returns Y coordinate of the mouse event position.


wxMouseEvent::IsButton

bool IsButton()

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


wxMouseEvent::Leaving

bool Leaving()

Returns TRUE if the mouse was leaving the window (MS Windows and Motif).

See also wxMouseEvent::Entering.


wxMouseEvent::LeftDClick

bool LeftDClick()

Returns TRUE if the event was a left double click.


wxMouseEvent::LeftDown

bool LeftDown()

Returns TRUE if the left mouse button changed to down.


wxMouseEvent::LeftIsDown

bool LeftIsDown()

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


wxMouseEvent::LeftUp

bool LeftUp()

Returns TRUE if the left mouse button changed to up.


wxMouseEvent::MetaDown

bool MetaDown()

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


wxMouseEvent::MiddleDClick

bool MiddleDClick()

Returns TRUE if the event was a middle double click.


wxMouseEvent::MiddleDown

bool MiddleDown()

Returns TRUE if the middle mouse button changed to down.


wxMouseEvent::MiddleIsDown

bool MiddleIsDown()

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


wxMouseEvent::MiddleUp

bool MiddleUp()

Returns TRUE if the middle mouse button changed to up.


wxMouseEvent::Moving

bool Moving()

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


wxMouseEvent::Position

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

wxMouseEvent::RightDClick

bool RightDClick()

Returns TRUE if the event was a right double click.


wxMouseEvent::RightDown

bool RightDown()

Returns TRUE if the right mouse button changed to down.


wxMouseEvent::RightIsDown

bool RightIsDown()

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


wxMouseEvent::RightUp

bool RightUp()

Returns TRUE if the right mouse button changed to up.


wxMouseEvent::ShiftDown

bool ShiftDown()

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