Contents Up Previous Next

wxMouseEvent: wxEvent

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


wxMouseEvent::controlDown

Bool controlDown

TRUE if control key is pressed down.


wxMouseEvent::leftDown

Bool leftDown

TRUE if the left mouse button is currently pressed down.


wxMouseEvent::middleDown

Bool middleDown

TRUE if the middle mouse button is currently pressed down.


wxMouseEvent::rightDown

Bool rightDown

TRUE if the right mouse button is currently pressed down.


wxMouseEvent::leftDown

Bool leftDown

TRUE if the left mouse button is currently pressed down.


wxMouseEvent::shiftDown

Bool shiftDown

TRUE if shift is pressed down.


wxMouseEvent::x

float x

X-coordinate of the event.


wxMouseEvent::y

float y

Y-coordinate of the event.


wxMouseEvent::wxMouseEvent

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.


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

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.


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(void)

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


wxMouseEvent::Dragging

Bool Dragging(void)

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


wxMouseEvent::Entering

Bool Entering(void)

Returns TRUE if the mouse was entering the canvas (MS Windows and Motif).

See also wxMouseEvent::Leaving.


wxMouseEvent::IsButton

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


wxMouseEvent::Leaving

Bool Leaving(void)

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

See also wxMouseEvent::Entering.


wxMouseEvent::LeftDClick

Bool LeftDClick(void)

Returns TRUE if the event was a left double click.


wxMouseEvent::LeftDown

Bool LeftDown(void)

Returns TRUE if the left mouse button changed to down.


wxMouseEvent::LeftIsDown

Bool LeftIsDown(void)

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


wxMouseEvent::LeftUp

Bool LeftUp(void)

Returns TRUE if the left mouse button changed to up.


wxMouseEvent::MiddleDClick

Bool MiddleDClick(void)

Returns TRUE if the event was a middle double click.


wxMouseEvent::MiddleDown

Bool MiddleDown(void)

Returns TRUE if the middle mouse button changed to down.


wxMouseEvent::MiddleIsDown

Bool MiddleIsDown(void)

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


wxMouseEvent::MiddleUp

Bool MiddleUp(void)

Returns TRUE if the middle mouse button changed to up.


wxMouseEvent::Moving

Bool Moving(void)

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

wxMouseEvent::RightDClick

Bool RightDClick(void)

Returns TRUE if the event was a right double click.


wxMouseEvent::RightDown

Bool RightDown(void)

Returns TRUE if the right mouse button changed to down.


wxMouseEvent::RightIsDown

Bool RightIsDown(void)

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


wxMouseEvent::RightUp

Bool RightUp(void)

Returns TRUE if the right mouse button changed to up.


wxMouseEvent::ShiftDown

Bool ShiftDown(void)

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