# Events
[Functions and Macros by Category]

## Detailed Description

Below are a number of functions/macros used with wxWidgets event-handling system.

Related class group: Events

## Defines
#define | wxDEFINE_EVENT(name, cls) const wxEventTypeTag< cls > name(wxNewEventType())
| Define a new event type associated with the specified event class.
#define | wxDECLARE_EVENT(name, cls) wxDECLARE_EXPORTED_EVENT(wxEMPTY_PARAMETER_VALUE, name, cls)
| Declares a custom event type.
#define | wxDECLARE_EXPORTED_EVENT(expdecl, name, cls) extern const expdecl wxEventTypeTag< cls > name;
| Variant of wxDECLARE_EVENT() used for event types defined inside a shared library.
#define | wxEVENT_HANDLER_CAST(functype, func) (&func)
| Helper macro for definition of custom event table macros.
#define | wx__DECLARE_EVT1(evt, id, fn) wx__DECLARE_EVT2(evt, id, wxID_ANY, fn)
| This macro is used to define event table macros for handling custom events.
#define | wx__DECLARE_EVT2(evt, id1, id2, fn) DECLARE_EVENT_TABLE_ENTRY(evt, id1, id2, fn, NULL),
| Generalized version of the wx__DECLARE_EVT1() macro taking a range of IDs instead of a single one.
#define | wx__DECLARE_EVT0(evt, fn) wx__DECLARE_EVT1(evt, wxID_ANY, fn)
| Simplified version of the wx__DECLARE_EVT1() macro, to be used when the event type must be handled regardless of the ID associated with the specific event instances.
#define | wxDECLARE_EVENT_TABLE()
| Use this macro inside a class declaration to declare a static event table for that class.
#define | wxBEGIN_EVENT_TABLE(theClass, baseClass)
| Use this macro in a source file to start listing static event handlers for a specific class.
#define | wxEND_EVENT_TABLE()
| Use this macro in a source file to end listing static event handlers for a specific class.
## Typedefs
typedef int | wxEventType
| A value uniquely identifying the type of the event.
## Functions
wxEventType | wxNewEventType ()
| Generates a new unique event type.
void | wxPostEvent (wxEvtHandler *dest, const wxEvent &event)
| In a GUI application, this function posts event to the specified dest object using wxEvtHandler::AddPendingEvent().
void | wxQueueEvent (wxEvtHandler *dest, wxEvent *event)
| Queue an event for processing on the given object.
## Variables
wxEventType | wxEVT_NULL
| A special event type usually used to indicate that some wxEvent has yet no type assigned.
wxEventType | wxEVT_ANY
wxEventType | wxEVT_COMMAND_BUTTON_CLICKED
wxEventType | wxEVT_COMMAND_CHECKBOX_CLICKED
wxEventType | wxEVT_COMMAND_CHOICE_SELECTED
wxEventType | wxEVT_COMMAND_LISTBOX_SELECTED
wxEventType | wxEVT_COMMAND_LISTBOX_DOUBLECLICKED
wxEventType | wxEVT_COMMAND_CHECKLISTBOX_TOGGLED
wxEventType | wxEVT_COMMAND_MENU_SELECTED
wxEventType | wxEVT_COMMAND_SLIDER_UPDATED
wxEventType | wxEVT_COMMAND_RADIOBOX_SELECTED
wxEventType | wxEVT_COMMAND_RADIOBUTTON_SELECTED
wxEventType | wxEVT_COMMAND_SCROLLBAR_UPDATED
wxEventType | wxEVT_COMMAND_VLBOX_SELECTED
wxEventType | wxEVT_COMMAND_COMBOBOX_SELECTED
wxEventType | wxEVT_COMMAND_TOOL_RCLICKED
wxEventType | wxEVT_COMMAND_TOOL_DROPDOWN_CLICKED
wxEventType | wxEVT_COMMAND_TOOL_ENTER
wxEventType | wxEVT_COMMAND_COMBOBOX_DROPDOWN
wxEventType | wxEVT_COMMAND_COMBOBOX_CLOSEUP
wxEventType | wxEVT_THREAD
wxEventType | wxEVT_LEFT_DOWN
wxEventType | wxEVT_LEFT_UP
wxEventType | wxEVT_MIDDLE_DOWN
wxEventType | wxEVT_MIDDLE_UP
wxEventType | wxEVT_RIGHT_DOWN
wxEventType | wxEVT_RIGHT_UP
wxEventType | wxEVT_MOTION
wxEventType | wxEVT_ENTER_WINDOW
wxEventType | wxEVT_LEAVE_WINDOW
wxEventType | wxEVT_LEFT_DCLICK
wxEventType | wxEVT_MIDDLE_DCLICK
wxEventType | wxEVT_RIGHT_DCLICK
wxEventType | wxEVT_SET_FOCUS
wxEventType | wxEVT_KILL_FOCUS
wxEventType | wxEVT_CHILD_FOCUS
wxEventType | wxEVT_MOUSEWHEEL
wxEventType | wxEVT_AUX1_DOWN
wxEventType | wxEVT_AUX1_UP
wxEventType | wxEVT_AUX1_DCLICK
wxEventType | wxEVT_AUX2_DOWN
wxEventType | wxEVT_AUX2_UP
wxEventType | wxEVT_AUX2_DCLICK
wxEventType | wxEVT_CHAR
wxEventType | wxEVT_CHAR_HOOK
wxEventType | wxEVT_NAVIGATION_KEY
wxEventType | wxEVT_KEY_DOWN
wxEventType | wxEVT_KEY_UP
wxEventType | wxEVT_HOTKEY
wxEventType | wxEVT_SET_CURSOR
wxEventType | wxEVT_SCROLL_TOP
wxEventType | wxEVT_SCROLL_BOTTOM
wxEventType | wxEVT_SCROLL_LINEUP
wxEventType | wxEVT_SCROLL_LINEDOWN
wxEventType | wxEVT_SCROLL_PAGEUP
wxEventType | wxEVT_SCROLL_PAGEDOWN
wxEventType | wxEVT_SCROLL_THUMBTRACK
wxEventType | wxEVT_SCROLL_THUMBRELEASE
wxEventType | wxEVT_SCROLL_CHANGED
wxEventType | wxEVT_SPIN_UP
wxEventType | wxEVT_SPIN_DOWN
wxEventType | wxEVT_SPIN
wxEventType | wxEVT_SCROLLWIN_TOP
wxEventType | wxEVT_SCROLLWIN_BOTTOM
wxEventType | wxEVT_SCROLLWIN_LINEUP
wxEventType | wxEVT_SCROLLWIN_LINEDOWN
wxEventType | wxEVT_SCROLLWIN_PAGEUP
wxEventType | wxEVT_SCROLLWIN_PAGEDOWN
wxEventType | wxEVT_SCROLLWIN_THUMBTRACK
wxEventType | wxEVT_SCROLLWIN_THUMBRELEASE
wxEventType | wxEVT_SIZE
wxEventType | wxEVT_MOVE
wxEventType | wxEVT_CLOSE_WINDOW
wxEventType | wxEVT_END_SESSION
wxEventType | wxEVT_QUERY_END_SESSION
wxEventType | wxEVT_ACTIVATE_APP
wxEventType | wxEVT_ACTIVATE
wxEventType | wxEVT_CREATE
wxEventType | wxEVT_DESTROY
wxEventType | wxEVT_SHOW
wxEventType | wxEVT_ICONIZE
wxEventType | wxEVT_MAXIMIZE
wxEventType | wxEVT_MOUSE_CAPTURE_CHANGED
wxEventType | wxEVT_MOUSE_CAPTURE_LOST
wxEventType | wxEVT_PAINT
wxEventType | wxEVT_ERASE_BACKGROUND
wxEventType | wxEVT_NC_PAINT
wxEventType | wxEVT_MENU_OPEN
wxEventType | wxEVT_MENU_CLOSE
wxEventType | wxEVT_MENU_HIGHLIGHT
wxEventType | wxEVT_CONTEXT_MENU
wxEventType | wxEVT_SYS_COLOUR_CHANGED
wxEventType | wxEVT_DISPLAY_CHANGED
wxEventType | wxEVT_QUERY_NEW_PALETTE
wxEventType | wxEVT_PALETTE_CHANGED
wxEventType | wxEVT_JOY_BUTTON_DOWN
wxEventType | wxEVT_JOY_BUTTON_UP
wxEventType | wxEVT_JOY_MOVE
wxEventType | wxEVT_JOY_ZMOVE
wxEventType | wxEVT_DROP_FILES
wxEventType | wxEVT_INIT_DIALOG
wxEventType | wxEVT_IDLE
wxEventType | wxEVT_UPDATE_UI
wxEventType | wxEVT_SIZING
wxEventType | wxEVT_MOVING
wxEventType | wxEVT_MOVE_START
wxEventType | wxEVT_MOVE_END
wxEventType | wxEVT_HIBERNATE
wxEventType | wxEVT_COMMAND_TEXT_COPY
wxEventType | wxEVT_COMMAND_TEXT_CUT
wxEventType | wxEVT_COMMAND_TEXT_PASTE
wxEventType | wxEVT_COMMAND_LEFT_CLICK
wxEventType | wxEVT_COMMAND_LEFT_DCLICK
wxEventType | wxEVT_COMMAND_RIGHT_CLICK
wxEventType | wxEVT_COMMAND_RIGHT_DCLICK
wxEventType | wxEVT_COMMAND_SET_FOCUS
wxEventType | wxEVT_COMMAND_KILL_FOCUS
wxEventType | wxEVT_COMMAND_ENTER
wxEventType | wxEVT_HELP
wxEventType | wxEVT_DETAILED_HELP
wxEventType | wxEVT_COMMAND_TEXT_UPDATED
wxEventType | wxEVT_COMMAND_TOOL_CLICKED

## Define Documentation

#define wx__DECLARE_EVT0 | ( | evt,
|  | fn |  | ) | wx__DECLARE_EVT1(evt, wxID_ANY, fn)

Simplified version of the wx__DECLARE_EVT1() macro, to be used when the event type must be handled regardless of the ID associated with the specific event instances.

#define wx__DECLARE_EVT1 | ( | evt,
|  | id,
|  | fn |  | ) | wx__DECLARE_EVT2(evt, id, wxID_ANY, fn)

This macro is used to define event table macros for handling custom events.

Example of use:

        class MyEvent : public wxEvent { ... };

        // note that this is not necessary unless using old compilers: for the
        // reasonably new ones just use &func instead of MyEventHandler(func)
        typedef void (wxEvtHandler::*MyEventFunction)(MyEvent&);
        #define MyEventHandler(func) wxEVENT_HANDLER_CAST(MyEventFunction, func)

        wxDEFINE_EVENT(MY_EVENT_TYPE, MyEvent);

        #define EVT_MY(id, func) \
            wx__DECLARE_EVT1(MY_EVENT_TYPE, id, MyEventHandler(func))

        ...

        wxBEGIN_EVENT_TABLE(MyFrame, wxFrame)
            EVT_MY(wxID_ANY, MyFrame::OnMyEvent)
        wxEND_EVENT_TABLE()

Parameters:

  | evt | The event type to handle.
  | id | The identifier of events to handle.
  | fn | The event handler method.

#define wx__DECLARE_EVT2 | ( | evt,
|  | id1,
|  | id2,
|  | fn |  | ) | DECLARE_EVENT_TABLE_ENTRY(evt, id1, id2, fn, NULL),

Generalized version of the wx__DECLARE_EVT1() macro taking a range of IDs instead of a single one.

Argument id1 is the first identifier of the range, id2 is the second identifier of the range.

#define wxBEGIN_EVENT_TABLE | ( | theClass,
|  | baseClass |  | ) |

Use this macro in a source file to start listing static event handlers for a specific class.

Use wxEND_EVENT_TABLE() to terminate the event-declaration block.

See also:
  Event Handling with Event Tables

#define wxDECLARE_EVENT | ( | name,
|  | cls |  | ) | wxDECLARE_EXPORTED_EVENT(wxEMPTY_PARAMETER_VALUE, name, cls)

Declares a custom event type.

This macro declares a variable called name which must be defined elsewhere using wxDEFINE_EVENT().

The class cls must be the wxEvent-derived class associated with the events of this type and its full declaration must be visible from the point of use of this macro.

For example:

        wxDECLARE_EVENT(MY_COMMAND_EVENT, wxCommandEvent);

        class MyCustomEvent : public wxEvent { ... };
        wxDECLARE_EVENT(MY_CUSTOM_EVENT, MyCustomEvent);

#define wxDECLARE_EVENT_TABLE | ( |  | ) |

Use this macro inside a class declaration to declare a static event table for that class.

In the implementation file you'll need to use the wxBEGIN_EVENT_TABLE() and the wxEND_EVENT_TABLE() macros, plus some additional `EVT_xxx` macro to capture events.

Note that this macro requires a final semicolon.

See also:
  Event Handling with Event Tables

#define wxDECLARE_EXPORTED_EVENT | ( | expdecl,
|  | name,
|  | cls |  | ) | extern const expdecl wxEventTypeTag< cls > name;

Variant of wxDECLARE_EVENT() used for event types defined inside a shared library.

This is mostly used by wxWidgets internally, e.g.

        wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEvent)

#define wxDEFINE_EVENT | ( | name,
|  | cls |  | ) | const wxEventTypeTag< cls > name(wxNewEventType())

Define a new event type associated with the specified event class.

This macro defines a new unique event type name associated with the event class cls.

For example:

        wxDEFINE_EVENT(MY_COMMAND_EVENT, wxCommandEvent);

        class MyCustomEvent : public wxEvent { ... };
        wxDEFINE_EVENT(MY_CUSTOM_EVENT, MyCustomEvent);

See also:
  wxDECLARE_EVENT(), Custom Event Summary

#define wxEND_EVENT_TABLE | ( |  | ) |

Use this macro in a source file to end listing static event handlers for a specific class.

Use wxBEGIN_EVENT_TABLE() to start the event-declaration block.

See also:
  Event Handling with Event Tables

#define wxEVENT_HANDLER_CAST | ( | functype,
|  | func |  | ) | (&func)

Helper macro for definition of custom event table macros.

This macro must only be used if wxEVENTS_COMPATIBILITY_2_8 is 1, otherwise it is better and more clear to just use the address of the function directly as this is all this macro does in this case. However it needs to explicitly cast func to functype, which is the type of wxEvtHandler member function taking the custom event argument when wxEVENTS_COMPATIBILITY_2_8 is 0.

See wx__DECLARE_EVT0 for an example of use.

See also:
  Defining Your Own Event Class

## Typedef Documentation

typedef int wxEventType

A value uniquely identifying the type of the event.

The values of this type should only be created using wxNewEventType().

See the macro DEFINE_EVENT_TYPE() for more info.

See also:
  Introduction to Events

## Function Documentation

wxEventType wxNewEventType | ( |  | ) |

Generates a new unique event type.

Usually this function is only used by wxDEFINE_EVENT() and not called directly.

void wxPostEvent | ( | wxEvtHandler * | dest,
|  | const wxEvent & | event |
| ) |  |  |

In a GUI application, this function posts event to the specified dest object using wxEvtHandler::AddPendingEvent().

Otherwise, it dispatches event immediately using wxEvtHandler::ProcessEvent(). See the respective documentation for details (and caveats). Because of limitation of wxEvtHandler::AddPendingEvent() this function is not thread-safe for event objects having wxString fields, use wxQueueEvent() instead.

Include file:

    #include <wx/event.h>

void wxQueueEvent | ( | wxEvtHandler * | dest,
|  | wxEvent * | event |
| ) |  |  |

Queue an event for processing on the given object.

This is a wrapper around wxEvtHandler::QueueEvent(), see its documentation for more details.

Include file:

    #include <wx/event.h>

Parameters:

  | dest | The object to queue the event on, can't be `NULL`.
  | event | The heap-allocated and non-`NULL` event to queue, the function takes ownership of it.

## Variable Documentation

wxEventType wxEVT_ACTIVATE

wxEventType wxEVT_ACTIVATE_APP

wxEventType wxEVT_ANY

wxEventType wxEVT_AUX1_DCLICK

wxEventType wxEVT_AUX1_DOWN

wxEventType wxEVT_AUX1_UP

wxEventType wxEVT_AUX2_DCLICK

wxEventType wxEVT_AUX2_DOWN

wxEventType wxEVT_AUX2_UP

wxEventType wxEVT_CHAR

wxEventType wxEVT_CHAR_HOOK

wxEventType wxEVT_CHILD_FOCUS

wxEventType wxEVT_CLOSE_WINDOW

wxEventType wxEVT_COMMAND_BUTTON_CLICKED

wxEventType wxEVT_COMMAND_CHECKBOX_CLICKED

wxEventType wxEVT_COMMAND_CHECKLISTBOX_TOGGLED

wxEventType wxEVT_COMMAND_CHOICE_SELECTED

wxEventType wxEVT_COMMAND_COMBOBOX_CLOSEUP

wxEventType wxEVT_COMMAND_COMBOBOX_DROPDOWN

wxEventType wxEVT_COMMAND_COMBOBOX_SELECTED

wxEventType wxEVT_COMMAND_ENTER

wxEventType wxEVT_COMMAND_KILL_FOCUS

wxEventType wxEVT_COMMAND_LEFT_CLICK

wxEventType wxEVT_COMMAND_LEFT_DCLICK

wxEventType wxEVT_COMMAND_LISTBOX_DOUBLECLICKED

wxEventType wxEVT_COMMAND_LISTBOX_SELECTED

wxEventType wxEVT_COMMAND_MENU_SELECTED

wxEventType wxEVT_COMMAND_RADIOBOX_SELECTED

wxEventType wxEVT_COMMAND_RADIOBUTTON_SELECTED

wxEventType wxEVT_COMMAND_RIGHT_CLICK

wxEventType wxEVT_COMMAND_RIGHT_DCLICK

wxEventType wxEVT_COMMAND_SCROLLBAR_UPDATED

wxEventType wxEVT_COMMAND_SET_FOCUS

wxEventType wxEVT_COMMAND_SLIDER_UPDATED

wxEventType wxEVT_COMMAND_TEXT_COPY

wxEventType wxEVT_COMMAND_TEXT_CUT

wxEventType wxEVT_COMMAND_TEXT_PASTE

wxEventType wxEVT_COMMAND_TEXT_UPDATED

wxEventType wxEVT_COMMAND_TOOL_CLICKED

wxEventType wxEVT_COMMAND_TOOL_DROPDOWN_CLICKED

wxEventType wxEVT_COMMAND_TOOL_ENTER

wxEventType wxEVT_COMMAND_TOOL_RCLICKED

wxEventType wxEVT_COMMAND_VLBOX_SELECTED

wxEventType wxEVT_CONTEXT_MENU

wxEventType wxEVT_CREATE

wxEventType wxEVT_DESTROY

wxEventType wxEVT_DETAILED_HELP

wxEventType wxEVT_DISPLAY_CHANGED

wxEventType wxEVT_DROP_FILES

wxEventType wxEVT_END_SESSION

wxEventType wxEVT_ENTER_WINDOW

wxEventType wxEVT_ERASE_BACKGROUND

wxEventType wxEVT_HELP

wxEventType wxEVT_HIBERNATE

wxEventType wxEVT_HOTKEY

wxEventType wxEVT_ICONIZE

wxEventType wxEVT_IDLE

wxEventType wxEVT_INIT_DIALOG

wxEventType wxEVT_JOY_BUTTON_DOWN

wxEventType wxEVT_JOY_BUTTON_UP

wxEventType wxEVT_JOY_MOVE

wxEventType wxEVT_JOY_ZMOVE

wxEventType wxEVT_KEY_DOWN

wxEventType wxEVT_KEY_UP

wxEventType wxEVT_KILL_FOCUS

wxEventType wxEVT_LEAVE_WINDOW

wxEventType wxEVT_LEFT_DCLICK

wxEventType wxEVT_LEFT_DOWN

wxEventType wxEVT_LEFT_UP

wxEventType wxEVT_MAXIMIZE

wxEventType wxEVT_MENU_CLOSE

wxEventType wxEVT_MENU_HIGHLIGHT

wxEventType wxEVT_MENU_OPEN

wxEventType wxEVT_MIDDLE_DCLICK

wxEventType wxEVT_MIDDLE_DOWN

wxEventType wxEVT_MIDDLE_UP

wxEventType wxEVT_MOTION

wxEventType wxEVT_MOUSE_CAPTURE_CHANGED

wxEventType wxEVT_MOUSE_CAPTURE_LOST

wxEventType wxEVT_MOUSEWHEEL

wxEventType wxEVT_MOVE

wxEventType wxEVT_MOVE_END

wxEventType wxEVT_MOVE_START

wxEventType wxEVT_MOVING

wxEventType wxEVT_NAVIGATION_KEY

wxEventType wxEVT_NC_PAINT

wxEventType wxEVT_NULL

A special event type usually used to indicate that some wxEvent has yet no type assigned.

wxEventType wxEVT_PAINT

wxEventType wxEVT_PALETTE_CHANGED

wxEventType wxEVT_QUERY_END_SESSION

wxEventType wxEVT_QUERY_NEW_PALETTE

wxEventType wxEVT_RIGHT_DCLICK

wxEventType wxEVT_RIGHT_DOWN

wxEventType wxEVT_RIGHT_UP

wxEventType wxEVT_SCROLL_BOTTOM

wxEventType wxEVT_SCROLL_CHANGED

wxEventType wxEVT_SCROLL_LINEDOWN

wxEventType wxEVT_SCROLL_LINEUP

wxEventType wxEVT_SCROLL_PAGEDOWN

wxEventType wxEVT_SCROLL_PAGEUP

wxEventType wxEVT_SCROLL_THUMBRELEASE

wxEventType wxEVT_SCROLL_THUMBTRACK

wxEventType wxEVT_SCROLL_TOP

wxEventType wxEVT_SCROLLWIN_BOTTOM

wxEventType wxEVT_SCROLLWIN_LINEDOWN

wxEventType wxEVT_SCROLLWIN_LINEUP

wxEventType wxEVT_SCROLLWIN_PAGEDOWN

wxEventType wxEVT_SCROLLWIN_PAGEUP

wxEventType wxEVT_SCROLLWIN_THUMBRELEASE

wxEventType wxEVT_SCROLLWIN_THUMBTRACK

wxEventType wxEVT_SCROLLWIN_TOP

wxEventType wxEVT_SET_CURSOR

wxEventType wxEVT_SET_FOCUS

wxEventType wxEVT_SHOW

wxEventType wxEVT_SIZE

wxEventType wxEVT_SIZING

wxEventType wxEVT_SPIN

wxEventType wxEVT_SPIN_DOWN

wxEventType wxEVT_SPIN_UP

wxEventType wxEVT_SYS_COLOUR_CHANGED

wxEventType wxEVT_THREAD

wxEventType wxEVT_UPDATE_UI

|  | [ top ]