An event is a general-purpose structure holding information about an event passed to a callback or member function. Call member functions of wxEvent to find out information appropriate to the kind of event, or query the wxWindow object itself (for example list box, canvas) to find out the status of the object.
wxEvent::wxEvent
voidwxEvent
Constructor. Should not need to be used by an application.
wxEvent::wxEvent
voidwxEvent
Destructor. Should not need to be used by an application.
wxEvent::Button
BoolButtonint button
Returns TRUE if the identified mouse button is changing state. Valid values of button are:
Not all mice have middle buttons so a portable application should avoid this one.
wxEvent::ButtonDown
BoolButtonDown
Returns TRUE if the event was a mouse button down event.
wxEvent::ControlDown
BoolControlDown
Returns TRUE if the control button was down at the time of the event.
wxEvent::Dragging
BoolDragging
Returns TRUE if this was a dragging event.
wxEvent::IsButton
BoolIsButton
Returns TRUE if the event was a mouse button event (not necessarily a button down event - that may be tested using ButtonDown).
wxEvent::LeftDown
BoolLeftDown
Returns TRUE if the left mouse button changed to down.
wxEvent::LeftUp
BoolLeftUp
Returns TRUE if the left mouse button changed to up.
wxEvent::MiddleDown
BoolMiddleDown
Returns TRUE if the middle mouse button changed to down.
wxEvent::MiddleUp
BoolMiddleUp
Returns TRUE if the middle mouse button changed to up.
wxEvent::Position
voidPositionfloat *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);
wxEvent::RightDown
BoolRightDown
Returns TRUE if the right mouse button changed to down.
wxEvent::RightUp
BoolRightUp
Returns TRUE if the right mouse button changed to up.
wxEvent::ShiftDown
BoolShiftDown
Returns TRUE if the shift button was down at the time of the event.