A class that can handle events from the windowing system. wxWindow (and therefore all window classes) are derived from this class.
Derived from
Include files
<wx/event.h>
See also
Members
wxEvtHandler::wxEvtHandler
wxEvtHandler::~wxEvtHandler
wxEvtHandler::Connect
wxEvtHandler::Default
wxEvtHandler::GetClientData
wxEvtHandler::GetEvtHandlerEnabled
wxEvtHandler::GetNextHandler
wxEvtHandler::GetPreviousHandler
wxEvtHandler::ProcessEvent
wxEvtHandler::SearchEventTable
wxEvtHandler::SetClientData
wxEvtHandler::SetEvtHandlerEnabled
wxEvtHandler::SetNextHandler
wxEvtHandler::SetPreviousHandler
wxEvtHandler()
Constructor.
~wxEvtHandler()
Destructor. If the handler is part of a chain, the destructor will unlink itself and restore the previous and next handlers so that they point to each other.
void Connect(int id, wxEventType eventType, wxObjectEventFunction function, wxObject* userData = NULL)
void Connect(int id, int lastId, wxEventType eventType, wxObjectEventFunction function, wxObject* userData = NULL)
Connects the given function dynamically with the event handler, id and event type. This is an alternative to the use of static event tables. See the 'dynamic' sample for usage.
Parameters
id
lastId
eventType
function
userData
Example
frame->Connect( wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) MyFrame::OnQuit );
virtual long Default()
Invokes default processing if this event handler is a window.
Return value
System dependent.
Remarks
A generic way of delegating processing to the default system behaviour. It calls a platform-dependent default function, with parameters dependent on the event or message parameters originally sent from the windowing system.
Normally the application should call a base member, such as wxWindow::OnChar, which itself may call Default.
char* GetClientData()
Gets user-supplied client data.
Remarks
Normally, any extra data the programmer wishes to associate with the object should be made available by deriving a new class with new data members.
See also
bool GetEvtHandlerEnabled()
Returns TRUE if the event handler is enabled, FALSE otherwise.
See also
wxEvtHandler::SetEvtHandlerEnabled
wxEvtHandler* GetNextHandler()
Gets the pointer to the next handler in the chain.
See also
wxEvtHandler::GetPreviousHandler, wxEvtHandler::SetPreviousHandler, wxEvtHandler::SetNextHandler, wxWindow::PushEventHandler, wxWindow::PopEventHandler
wxEvtHandler* GetPreviousHandler()
Gets the pointer to the previous handler in the chain.
See also
wxEvtHandler::GetPreviousHandler, wxEvtHandler::SetPreviousHandler, wxEvtHandler::SetPreviousHandler, wxWindow::PushEventHandler, wxWindow::PopEventHandler
virtual bool ProcessEvent(wxEvent& event)
Processes an event, searching event tables and calling zero or more suitable event handler function(s).
Parameters
event
Return value
TRUE if a suitable event handler function was found and executed, and the function did not call wxEvent::Skip.
Remarks
Normally, your application would not call this function: it is called in the wxWindows implementation to dispatch incoming user interface events to the framework (and application).
However, you might need to call it if implementing new functionality (such as a new control) where you define new event types, as opposed to allowing the user to override virtual functions.
An instance where you might actually override the ProcessEvent function is where you want to direct event processing to event handlers not normally noticed by wxWindows. For example, in the document/view architecture, documents and views are potential event handlers. When an event reaches a frame, ProcessEvent will need to be called on the associated document and view in case event handler functions are associated with these objects. The property classes library (wxProperty) also overrides ProcessEvent for similar reasons.
The normal order of event table searching is as follows:
See also
wxEvtHandler::SearchEventTable
bool SearchEventTable(wxEventTable& table, wxEvent& event)
Searches the event table, executing an event handler function if an appropriate one is found.
Parameters
table
event
Return value
TRUE if a suitable event handler function was found and executed, and the function did not call wxEvent::Skip.
Remarks
This function looks through the object's event table and tries to find an entry that will match the event.
An entry will match if:
If a suitable function is called but calls wxEvent::Skip, this function will fail, and searching will continue.
See also
void SetClientData(char* data)
Sets user-supplied client data.
Parameters
data
Remarks
Normally, any extra data the programmer wishes to associate with the object should be made available by deriving a new class with new data members. See also
void SetEvtHandlerEnabled(bool enabled)
Enables or disables the event handler.
Parameters
enabled
Remarks
You can use this function to avoid having to remove the event handler from the chain, for example when implementing a dialog editor and changing from edit to test mode.
See also
wxEvtHandler::GetEvtHandlerEnabled
void SetNextHandler(wxEvtHandler* handler)
Sets the pointer to the next handler.
Parameters
handler
See also
wxEvtHandler::GetNextHandler, wxEvtHandler::SetPreviousHandler, wxEvtHandler::GetPreviousHandler, wxWindow::PushEventHandler, wxWindow::PopEventHandler
void SetPreviousHandler(wxEvtHandler* handler)
Sets the pointer to the previous handler.
Parameters
handler
See also
wxEvtHandler::GetPreviousHandler, wxEvtHandler::SetNextHandler, wxEvtHandler::GetNextHandler, wxWindow::PushEventHandler, wxWindow::PopEventHandler