Contents Up Previous Next

System event functions

The wxWindows system event implementation is incomplete and experimental, but is intended to be a platform-independent way of intercepting and sending events, including defining application-specific events and handlers.

Ultimately it is intended to be used as a way of testing wxWindows applications using scripts, although there are currently problems with this (especially with modal dialogs).

All this is documented more to provoke comments and suggestions, and jog my own memory, rather than to be used, since it has not been tested. However wxSendEvent will probably work if you instantiate the event structure properly for a command event type (see the code in wb_panel.cpp for wxPanel::OnDefaultAction which uses wxSendEvent to send a command to the default button).

::wxAddPrimaryEventHandler
::wxAddSecondaryEventHandler
::wxNotifyEvent
::wxRegisterEventClass
::wxRegisterEventName
::wxRegisterExternalEventHandlers
::wxRemoveSecondaryEventHandler
::wxSendEvent


::wxAddPrimaryEventHandler

Bool wxAddPrimaryEventHandler(wxEventHandler handlerFunc)

Add a primary event handler---the normal event handler for this event. For built-in events, these would include moving and resizing windows. User-defined primary events might include the code to select an image in a diagram (which could of course be achieved by a series of external events for mouse-clicking, but would be more difficult to specify and less robust).

Returns TRUE if it succeeds.

An event handler takes a pointer to a wxEvent and a boolean flag which is TRUE if the event was externally generated, and returns a boolean which is TRUE if that event was handled.


::wxAddSecondaryEventHandler

Bool wxAddSecondaryEventHandler(wxEventHandler handlerFunc, Bool pre,
Bool override, Bool append)

Add a secondary event handler, pre = TRUE iff it should be called before the event is executed. override = TRUE iff the handler is allowed to override all subsequent events by returning TRUE. Returns TRUE if succeeds.

A secondary event handler is an application-defined handler that may intercept normal events, possibly overriding them. A primary event handler provides the normal behaviour for the event.

An event handler takes a pointer to a wxEvent and a boolean flag which is TRUE if the event was externally generated, and returns a boolean which is TRUE if that event was handled.


::wxNotifyEvent

Bool wxNotifyEvent(wxEvent& event, Bool pre)

Notify the system of the event you are about to execute/have just executed. If TRUE is returned and pre = TRUE, the calling code should not execute the event (since it has been intercepted by a handler and vetoed).

These events are always internal, because they're generated from within the main application code.


::wxRegisterEventClass

void wxRegisterEventClass(WXTYPE eventClassId,WXTYPE superClassId,
wxEventConstructor constructor, char *description)

Register a new event class (derived from wxEvent), giving the new event class type, its superclass, a function for creating a new event object of this class, and an optional description.


::wxRegisterEventName

void wxRegisterEventName(WXTYPE eventTypeId,WXTYPE eventClassId,
char *eventName)

Register the name of the event. This will allow a simple command language where giving the event type name and some arguments will cause a new event of class eventClassId to be created, with given event type, and some arguments, allows an event to be dynamically constructed and sent.


::wxRegisterExternalEventHandlers

void wxRegisterExternalEventHandlers(void)

Define this and link before wxWindows library to allow registering events from 'outside' the main application.


::wxRemoveSecondaryEventHandler

Bool wxRemoveSecondaryEventHandler(wxEventHandler handlerFunc, Bool pre)

Remove a secondary event handler. Returns TRUE if it succeeds.


::wxSendEvent

Bool wxSendEvent(wxEvent& event, Bool external)

Send an event to the system; usually it will be external, but set external to FALSE if calling from within the main application in response to other events.

Returns TRUE if the event was processed.