The wxWindows event system

From Version 1.5, wxWindows has its own event system. Event classes are derived from the abstract base class wxEvent (which used to serve as a holder for canvas and panel item events). An event class encapsulates a range of similar event types. For example, the instances of the wxMouseEvent class may be generated for a number of event types such as wxEVENT_TYPE_LEFT_DOWN.

There are several motivations for having an explicit representation for events.

Firstly, encapsulating events in structures makes sense compared with passing an event handler a large number of arguments.

Secondly, user input events may be simulated by sending events; this can be used for automating GUI testing, and events could (in theory) be stored for later playback.

Thirdly, event handlers can be installed by programs or 'meta-programs' which want to override or examine program behaviour. For example, special-needs access code could be written to enable GUI events to be expressed to the user in a non-graphical form. Or, a meta-program could examine the dialog structure of a running application and output a skeleton help file corresponding to the application's hierarchy of menus and dialogs, taking some of the donkey work out of preparing on-line help.

The event system is meant to be user-extensible so that any GUI-related or application-specific events may be defined and used in a consistent way. However, it is not yet completed and documented, and it is expected to evolve over the next few releases. The eventual aim is an event system which is comprehensive enough to enable wxWindows programs to be tested automatically using scripts (possibly using NASA's CLIPS as the scripting language -- see CLIPS).