This event class contains information about mouse events, particularly events received by canvases. See wxCanvas::OnEvent.
wxMouseEvent::controlDown
wxMouseEvent::leftDown
wxMouseEvent::middleDown
wxMouseEvent::rightDown
wxMouseEvent::leftDown
wxMouseEvent::shiftDown
wxMouseEvent::x
wxMouseEvent::y
wxMouseEvent::wxMouseEvent
wxMouseEvent::Button
wxMouseEvent::ButtonDClick
wxMouseEvent::ButtonDown
wxMouseEvent::ButtonUp
wxMouseEvent::ControlDown
wxMouseEvent::Dragging
wxMouseEvent::Entering
wxMouseEvent::IsButton
wxMouseEvent::Leaving
wxMouseEvent::LeftDClick
wxMouseEvent::LeftDown
wxMouseEvent::LeftIsDown
wxMouseEvent::LeftUp
wxMouseEvent::MiddleDClick
wxMouseEvent::MiddleDown
wxMouseEvent::MiddleIsDown
wxMouseEvent::MiddleUp
wxMouseEvent::Moving
wxMouseEvent::Position
wxMouseEvent::RightDClick
wxMouseEvent::RightDown
wxMouseEvent::RightIsDown
wxMouseEvent::RightUp
wxMouseEvent::ShiftDown
Bool controlDown
TRUE if control key is pressed down.
Bool leftDown
TRUE if the left mouse button is currently pressed down.
Bool middleDown
TRUE if the middle mouse button is currently pressed down.
Bool rightDown
TRUE if the right mouse button is currently pressed down.
Bool leftDown
TRUE if the left mouse button is currently pressed down.
Bool shiftDown
TRUE if shift is pressed down.
float x
X-coordinate of the event.
float y
Y-coordinate of the event.
void wxMouseEvent(WXTYPE mouseEventType)
Constructor. Valid event types are:
Note that double clicks in canvases are only processed if you call wxWindow::SetDoubleClick with a value of TRUE.
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).
Under MS Windows, a double click always follows a down-up sequence. On the other supported platforms (WIN32, Motif, but not XView) the double click event occurs on its own. See also wxCanvas::AllowDoubleClick.
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(void)
Returns TRUE if the control key was down at the time of the event.
Bool Dragging(void)
Returns TRUE if this was a dragging event (motion while a button is depressed).
Bool Entering(void)
Returns TRUE if the mouse was entering the canvas (MS Windows and Motif).
See also wxMouseEvent::Leaving.
Bool IsButton(void)
Returns TRUE if the event was a mouse button event (not necessarily a button down event - that may be tested using ButtonDown).
Bool Leaving(void)
Returns TRUE if the mouse was leaving the canvas (MS Windows and Motif).
See also wxMouseEvent::Entering.
Bool LeftDClick(void)
Returns TRUE if the event was a left double click.
Bool LeftDown(void)
Returns TRUE if the left mouse button changed to down.
Bool LeftIsDown(void)
Returns TRUE if the left mouse button is currently down, independent of the current event type.
Bool LeftUp(void)
Returns TRUE if the left mouse button changed to up.
Bool MiddleDClick(void)
Returns TRUE if the event was a middle double click.
Bool MiddleDown(void)
Returns TRUE if the middle mouse button changed to down.
Bool MiddleIsDown(void)
Returns TRUE if the middle mouse button is currently down, independent of the current event type.
Bool MiddleUp(void)
Returns TRUE if the middle mouse button changed to up.
Bool Moving(void)
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 canvas, 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 canvas mouse event), use wxDC::LogicalToDeviceX and wxDC::LogicalToDeviceY.
For example, the following code calculates screen pixel coordinates from the frame position, canvas view start (assuming the canvas 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); canvas->ViewStart(&x1, &y1); int mouse_x = (int)(canvas->GetDC()->LogicalToDeviceX(event_x + x - x1); int mouse_y = (int)(canvas->GetDC()->LogicalToDeviceY(event_y + y - y1); char *choice = wxGetSingleChoice("Menu", "Pick a node action", no_choices, choices, frame, mouse_x, mouse_y);
Bool RightDClick(void)
Returns TRUE if the event was a right double click.
Bool RightDown(void)
Returns TRUE if the right mouse button changed to down.
Bool RightIsDown(void)
Returns TRUE if the right mouse button is currently down, independent of the current event type.
Bool RightUp(void)
Returns TRUE if the right mouse button changed to up.
Bool ShiftDown(void)
Returns TRUE if the shift key was down at the time of the event.