1998-05-20 10:25:30 -04:00
|
|
|
\section{\class{wxEvtHandler}}\label{wxevthandler}
|
|
|
|
|
|
|
|
A class that can handle events from the windowing system.
|
|
|
|
wxWindow (and therefore all window classes) are derived from
|
|
|
|
this class.
|
|
|
|
|
|
|
|
\wxheading{Derived from}
|
|
|
|
|
|
|
|
\helpref{wxObject}{wxobject}
|
|
|
|
|
1999-02-15 15:41:29 -05:00
|
|
|
\wxheading{Include files}
|
|
|
|
|
|
|
|
<wx/event.h>
|
|
|
|
|
1998-05-20 10:25:30 -04:00
|
|
|
\wxheading{See also}
|
|
|
|
|
|
|
|
\overview{Event handling overview}{eventhandlingoverview}
|
|
|
|
|
|
|
|
\latexignore{\rtfignore{\wxheading{Members}}}
|
|
|
|
|
|
|
|
\membersection{wxEvtHandler::wxEvtHandler}
|
|
|
|
|
|
|
|
\func{}{wxEvtHandler}{\void}
|
|
|
|
|
|
|
|
Constructor.
|
|
|
|
|
|
|
|
\membersection{wxEvtHandler::\destruct{wxEvtHandler}}
|
|
|
|
|
|
|
|
\func{}{\destruct{wxEvtHandler}}{\void}
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
1999-11-21 13:31:03 -05:00
|
|
|
\membersection{wxEvtHandler::AddPendingEvent}\label{wxevthandleraddpendingevent}
|
|
|
|
|
|
|
|
\func{virtual void}{AddPendingEvent}{\param{wxEvent\& }{event}}
|
|
|
|
|
2001-11-18 07:42:45 -05:00
|
|
|
This function posts an event to be processed later.
|
1999-11-21 13:31:03 -05:00
|
|
|
|
|
|
|
\wxheading{Parameters}
|
|
|
|
|
|
|
|
\docparam{event}{Event to add to process queue.}
|
|
|
|
|
|
|
|
\wxheading{Remarks}
|
|
|
|
|
2001-11-18 07:42:45 -05:00
|
|
|
The difference between sending an event (using the
|
|
|
|
\helpref{ProcessEvent}{wxevthandlerprocessevent} method) and posting it is
|
|
|
|
that in the first case the event is processed before the function returns,
|
|
|
|
while in the second case, the function returns immediately and the event will
|
|
|
|
be processed sometime later (usually during the next event loop iteration).
|
|
|
|
|
|
|
|
A copy of {\it event} is made by the function, so the original can be deleted
|
|
|
|
as soon as function returns (it is common that the original is created on the
|
|
|
|
stack). This requires that the \helpref{wxEvent::Clone}{wxeventclone} method
|
|
|
|
be implemented by {\it event} so that it can be duplicated and stored until
|
|
|
|
it gets processed.
|
|
|
|
|
|
|
|
This is also the method to call for inter-thread communication---it will
|
|
|
|
post events safely between different threads which means that this method is
|
|
|
|
thread-safe by using critical sections where needed. In a multi-threaded
|
|
|
|
program, you often need to inform the main GUI thread about the status of
|
|
|
|
other working threads and such notification should be done using this method.
|
|
|
|
|
|
|
|
This method automatically wakes up idle handling if the underlying window
|
|
|
|
system is currently idle and thus would not send any idle events. (Waking
|
|
|
|
up idle handling is done calling \helpref{::wxWakeUpIdle}{wxwakeupidle}.)
|
1999-11-21 13:31:03 -05:00
|
|
|
|
1998-12-23 04:58:02 -05:00
|
|
|
\membersection{wxEvtHandler::Connect}\label{wxevthandlerconnect}
|
|
|
|
|
|
|
|
\func{void}{Connect}{\param{int}{ id},
|
|
|
|
\param{wxEventType }{eventType}, \param{wxObjectEventFunction}{ function},
|
|
|
|
\param{wxObject*}{ userData = NULL}}
|
|
|
|
|
|
|
|
\func{void}{Connect}{\param{int}{ id}, \param{int}{ lastId},
|
|
|
|
\param{wxEventType }{eventType}, \param{wxObjectEventFunction}{ function},
|
|
|
|
\param{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.
|
|
|
|
|
|
|
|
\wxheading{Parameters}
|
|
|
|
|
|
|
|
\docparam{id}{The identifier (or first of the identifier range) to be associated with the event handler function.}
|
|
|
|
|
|
|
|
\docparam{lastId}{The second part of the identifier range to be associated with the event handler function.}
|
|
|
|
|
|
|
|
\docparam{eventType}{The event type to be associated with this event handler.}
|
|
|
|
|
|
|
|
\docparam{function}{The event handler function.}
|
|
|
|
|
|
|
|
\docparam{userData}{Data to be associated with the event table entry.}
|
|
|
|
|
|
|
|
\wxheading{Example}
|
|
|
|
|
|
|
|
\begin{verbatim}
|
|
|
|
frame->Connect( wxID_EXIT,
|
|
|
|
wxEVT_COMMAND_MENU_SELECTED,
|
|
|
|
(wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) MyFrame::OnQuit );
|
|
|
|
\end{verbatim}
|
|
|
|
|
1999-11-21 13:31:03 -05:00
|
|
|
\membersection{wxEvtHandler::Disconnect}\label{wxevthandlerdisconnect}
|
|
|
|
|
|
|
|
\func{bool}{Disconnect}{\param{int}{ id},
|
1999-12-24 18:40:13 -05:00
|
|
|
\param{wxEventType }{eventType = wxEVT\_NULL}, \param{wxObjectEventFunction}{ function = NULL},
|
1999-11-21 13:31:03 -05:00
|
|
|
\param{wxObject*}{ userData = NULL}}
|
|
|
|
|
|
|
|
\func{bool}{Disconnect}{\param{int}{ id}, \param{int}{ lastId = -1},
|
1999-12-24 18:40:13 -05:00
|
|
|
\param{wxEventType }{eventType = wxEVT\_NULL}, \param{wxObjectEventFunction}{ function = NULL},
|
1999-11-21 13:31:03 -05:00
|
|
|
\param{wxObject*}{ userData = NULL}}
|
1998-05-20 10:25:30 -04:00
|
|
|
|
1999-11-21 13:31:03 -05:00
|
|
|
Disconnects the given function dynamically from the event handler, using the specified
|
1999-11-22 07:13:55 -05:00
|
|
|
parameters as search criteria and returning TRUE if a matching function has been
|
|
|
|
found and removed. This method can only disconnect functions which have been added
|
1999-11-21 13:31:03 -05:00
|
|
|
using the \helpref{wxEvtHandler::Connect}{wxevthandlerconnect} method. There is no way
|
1999-11-22 07:13:55 -05:00
|
|
|
to disconnect functions connected using the (static) event tables.
|
1998-05-20 10:25:30 -04:00
|
|
|
|
1999-11-21 13:31:03 -05:00
|
|
|
\wxheading{Parameters}
|
1998-05-20 10:25:30 -04:00
|
|
|
|
1999-11-21 13:31:03 -05:00
|
|
|
\docparam{id}{The identifier (or first of the identifier range) associated with the event handler function.}
|
1998-05-20 10:25:30 -04:00
|
|
|
|
1999-11-21 13:31:03 -05:00
|
|
|
\docparam{lastId}{The second part of the identifier range associated with the event handler function.}
|
1998-05-20 10:25:30 -04:00
|
|
|
|
1999-11-21 13:31:03 -05:00
|
|
|
\docparam{eventType}{The event type associated with this event handler.}
|
1998-05-20 10:25:30 -04:00
|
|
|
|
1999-11-21 13:31:03 -05:00
|
|
|
\docparam{function}{The event handler function.}
|
1998-05-20 10:25:30 -04:00
|
|
|
|
1999-11-22 07:13:55 -05:00
|
|
|
\docparam{userData}{Data associated with the event table entry.}
|
1998-05-20 10:25:30 -04:00
|
|
|
|
|
|
|
\membersection{wxEvtHandler::GetClientData}\label{wxevthandlergetclientdata}
|
|
|
|
|
1999-11-22 07:13:55 -05:00
|
|
|
\func{void* }{GetClientData}{\void}
|
1998-05-20 10:25:30 -04:00
|
|
|
|
|
|
|
Gets user-supplied client data.
|
|
|
|
|
|
|
|
\wxheading{Remarks}
|
|
|
|
|
|
|
|
Normally, any extra data the programmer wishes to associate with the object
|
1999-11-22 07:13:55 -05:00
|
|
|
should be made available by deriving a new class with new data members.
|
1998-05-20 10:25:30 -04:00
|
|
|
|
|
|
|
\wxheading{See also}
|
|
|
|
|
|
|
|
\helpref{wxEvtHandler::SetClientData}{wxevthandlersetclientdata}
|
|
|
|
|
2002-05-31 03:41:46 -04:00
|
|
|
\membersection{wxEvtHandler::GetClientObject}\label{wxevthandlergetclientobject}
|
|
|
|
|
|
|
|
\constfunc{wxClientData*}{GetClientObject}{\void}
|
|
|
|
|
|
|
|
Get a pointer to the user-supplied client data object.
|
|
|
|
|
|
|
|
\wxheading{See also}
|
|
|
|
|
|
|
|
\helpref{wxEvtHandler::SetClientObject}{wxevthandlersetclientobject},
|
|
|
|
\helpref{wxClientData}{wxclientdata}
|
|
|
|
|
1998-05-20 10:25:30 -04:00
|
|
|
\membersection{wxEvtHandler::GetEvtHandlerEnabled}\label{wxevthandlergetevthandlerenabled}
|
|
|
|
|
|
|
|
\func{bool}{GetEvtHandlerEnabled}{\void}
|
|
|
|
|
|
|
|
Returns TRUE if the event handler is enabled, FALSE otherwise.
|
|
|
|
|
|
|
|
\wxheading{See also}
|
|
|
|
|
|
|
|
\helpref{wxEvtHandler::SetEvtHandlerEnabled}{wxevthandlersetevthandlerenabled}
|
|
|
|
|
|
|
|
\membersection{wxEvtHandler::GetNextHandler}\label{wxevthandlergetnexthandler}
|
|
|
|
|
|
|
|
\func{wxEvtHandler*}{GetNextHandler}{\void}
|
|
|
|
|
|
|
|
Gets the pointer to the next handler in the chain.
|
|
|
|
|
|
|
|
\wxheading{See also}
|
|
|
|
|
1999-10-08 07:56:57 -04:00
|
|
|
\helpref{wxEvtHandler::SetNextHandler}{wxevthandlersetnexthandler},\rtfsp
|
1998-05-20 10:25:30 -04:00
|
|
|
\helpref{wxEvtHandler::GetPreviousHandler}{wxevthandlergetprevioushandler},\rtfsp
|
|
|
|
\helpref{wxEvtHandler::SetPreviousHandler}{wxevthandlersetprevioushandler},\rtfsp
|
|
|
|
\helpref{wxWindow::PushEventHandler}{wxwindowpusheventhandler},\rtfsp
|
|
|
|
\helpref{wxWindow::PopEventHandler}{wxwindowpopeventhandler}
|
|
|
|
|
|
|
|
\membersection{wxEvtHandler::GetPreviousHandler}\label{wxevthandlergetprevioushandler}
|
|
|
|
|
|
|
|
\func{wxEvtHandler*}{GetPreviousHandler}{\void}
|
|
|
|
|
|
|
|
Gets the pointer to the previous handler in the chain.
|
|
|
|
|
|
|
|
\wxheading{See also}
|
|
|
|
|
|
|
|
\helpref{wxEvtHandler::SetPreviousHandler}{wxevthandlersetprevioushandler},\rtfsp
|
1999-10-08 07:56:57 -04:00
|
|
|
\helpref{wxEvtHandler::GetNextHandler}{wxevthandlergetnexthandler},\rtfsp
|
|
|
|
\helpref{wxEvtHandler::SetNextHandler}{wxevthandlersetnexthandler},\rtfsp
|
1998-05-20 10:25:30 -04:00
|
|
|
\helpref{wxWindow::PushEventHandler}{wxwindowpusheventhandler},\rtfsp
|
|
|
|
\helpref{wxWindow::PopEventHandler}{wxwindowpopeventhandler}
|
|
|
|
|
|
|
|
\membersection{wxEvtHandler::ProcessEvent}\label{wxevthandlerprocessevent}
|
|
|
|
|
|
|
|
\func{virtual bool}{ProcessEvent}{\param{wxEvent\& }{event}}
|
|
|
|
|
|
|
|
Processes an event, searching event tables and calling zero or more suitable event handler function(s).
|
|
|
|
|
|
|
|
\wxheading{Parameters}
|
|
|
|
|
|
|
|
\docparam{event}{Event to process.}
|
|
|
|
|
|
|
|
\wxheading{Return value}
|
|
|
|
|
|
|
|
TRUE if a suitable event handler function was found and executed, and the function did not
|
|
|
|
call \helpref{wxEvent::Skip}{wxeventskip}.
|
|
|
|
|
|
|
|
\wxheading{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 {\bf 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, {\bf 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 {\bf ProcessEvent} for similar reasons.
|
|
|
|
|
|
|
|
The normal order of event table searching is as follows:
|
|
|
|
|
|
|
|
\begin{enumerate}\itemsep=0pt
|
|
|
|
\item If the object is disabled (via a call to \helpref{wxEvtHandler::SetEvtHandlerEnabled}{wxevthandlersetevthandlerenabled})
|
|
|
|
the function skips to step (6).
|
|
|
|
\item If the object is a wxWindow, {\bf ProcessEvent} is recursively called on the window's\rtfsp
|
|
|
|
\helpref{wxValidator}{wxvalidator}. If this returns TRUE, the function exits.
|
|
|
|
\item {\bf SearchEventTable} is called for this event handler. If this fails, the base
|
|
|
|
class table is tried, and so on until no more tables exist or an appropriate function was found,
|
|
|
|
in which case the function exits.
|
|
|
|
\item The search is applied down the entire chain of event handlers (usually the chain has a length
|
|
|
|
of one). If this succeeds, the function exits.
|
|
|
|
\item If the object is a wxWindow and the event is a wxCommandEvent, {\bf ProcessEvent} is
|
|
|
|
recursively applied to the parent window's event handler. If this returns TRUE, the function exits.
|
|
|
|
\item Finally, {\bf ProcessEvent} is called on the wxApp object.
|
|
|
|
\end{enumerate}
|
|
|
|
|
|
|
|
\wxheading{See also}
|
|
|
|
|
|
|
|
\helpref{wxEvtHandler::SearchEventTable}{wxevthandlersearcheventtable}
|
|
|
|
|
|
|
|
\membersection{wxEvtHandler::SearchEventTable}\label{wxevthandlersearcheventtable}
|
|
|
|
|
|
|
|
\func{bool}{SearchEventTable}{\param{wxEventTable\& }{table}, \param{wxEvent\& }{event}}
|
|
|
|
|
|
|
|
Searches the event table, executing an event handler function if an appropriate one
|
|
|
|
is found.
|
|
|
|
|
|
|
|
\wxheading{Parameters}
|
|
|
|
|
|
|
|
\docparam{table}{Event table to be searched.}
|
|
|
|
|
|
|
|
\docparam{event}{Event to be matched against an event table entry.}
|
|
|
|
|
|
|
|
\wxheading{Return value}
|
|
|
|
|
|
|
|
TRUE if a suitable event handler function was found and executed, and the function did not
|
|
|
|
call \helpref{wxEvent::Skip}{wxeventskip}.
|
|
|
|
|
|
|
|
\wxheading{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:
|
|
|
|
|
|
|
|
\begin{enumerate}\itemsep=0pt
|
|
|
|
\item The event type matches, and
|
|
|
|
\item the identifier or identifier range matches, or the event table entry's identifier is zero.
|
|
|
|
\end{enumerate}
|
|
|
|
|
|
|
|
If a suitable function is called but calls \helpref{wxEvent::Skip}{wxeventskip}, this function will
|
|
|
|
fail, and searching will continue.
|
|
|
|
|
|
|
|
\wxheading{See also}
|
|
|
|
|
|
|
|
\helpref{wxEvtHandler::ProcessEvent}{wxevthandlerprocessevent}
|
|
|
|
|
|
|
|
\membersection{wxEvtHandler::SetClientData}\label{wxevthandlersetclientdata}
|
|
|
|
|
1999-11-22 07:13:55 -05:00
|
|
|
\func{void}{SetClientData}{\param{void* }{data}}
|
1998-05-20 10:25:30 -04:00
|
|
|
|
|
|
|
Sets user-supplied client data.
|
|
|
|
|
|
|
|
\wxheading{Parameters}
|
|
|
|
|
|
|
|
\docparam{data}{Data to be associated with the event handler.}
|
|
|
|
|
|
|
|
\wxheading{Remarks}
|
|
|
|
|
1999-11-22 07:13:55 -05:00
|
|
|
Normally, any extra data the programmer wishes to associate with
|
|
|
|
the object should be made available by deriving a new class
|
2002-05-31 03:41:46 -04:00
|
|
|
with new data members. You must not call this method and
|
|
|
|
\helpref{SetClientObject}{wxevthandlersetclientobject} on the
|
|
|
|
same class - only one of them.
|
1998-05-20 10:25:30 -04:00
|
|
|
|
|
|
|
\wxheading{See also}
|
|
|
|
|
|
|
|
\helpref{wxEvtHandler::GetClientData}{wxevthandlergetclientdata}
|
|
|
|
|
2002-05-31 03:41:46 -04:00
|
|
|
\membersection{wxEvtHandler::SetClientObject}\label{wxevthandlersetclientobject}
|
|
|
|
|
|
|
|
\func{void}{SetClientObject}{\param{wxClientData* }{data}}
|
|
|
|
|
|
|
|
Set the client data object. Any previous object will be deleted.
|
|
|
|
|
|
|
|
\wxheading{See also}
|
|
|
|
|
|
|
|
\helpref{wxEvtHandler::GetClientObject}{wxevthandlergetclientobject},
|
|
|
|
\helpref{wxClientData}{wxclientdata}
|
|
|
|
|
1998-05-20 10:25:30 -04:00
|
|
|
\membersection{wxEvtHandler::SetEvtHandlerEnabled}\label{wxevthandlersetevthandlerenabled}
|
|
|
|
|
|
|
|
\func{void}{SetEvtHandlerEnabled}{\param{bool }{enabled}}
|
|
|
|
|
|
|
|
Enables or disables the event handler.
|
|
|
|
|
|
|
|
\wxheading{Parameters}
|
|
|
|
|
|
|
|
\docparam{enabled}{TRUE if the event handler is to be enabled, FALSE if it is to be disabled.}
|
|
|
|
|
|
|
|
\wxheading{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.
|
|
|
|
|
|
|
|
\wxheading{See also}
|
|
|
|
|
|
|
|
\helpref{wxEvtHandler::GetEvtHandlerEnabled}{wxevthandlergetevthandlerenabled}
|
|
|
|
|
|
|
|
\membersection{wxEvtHandler::SetNextHandler}\label{wxevthandlersetnexthandler}
|
|
|
|
|
|
|
|
\func{void}{SetNextHandler}{\param{wxEvtHandler* }{handler}}
|
|
|
|
|
|
|
|
Sets the pointer to the next handler.
|
|
|
|
|
|
|
|
\wxheading{Parameters}
|
|
|
|
|
|
|
|
\docparam{handler}{Event handler to be set as the next handler.}
|
|
|
|
|
|
|
|
\wxheading{See also}
|
|
|
|
|
|
|
|
\helpref{wxEvtHandler::GetNextHandler}{wxevthandlergetnexthandler},\rtfsp
|
|
|
|
\helpref{wxEvtHandler::SetPreviousHandler}{wxevthandlersetprevioushandler},\rtfsp
|
|
|
|
\helpref{wxEvtHandler::GetPreviousHandler}{wxevthandlergetprevioushandler},\rtfsp
|
|
|
|
\helpref{wxWindow::PushEventHandler}{wxwindowpusheventhandler},\rtfsp
|
|
|
|
\helpref{wxWindow::PopEventHandler}{wxwindowpopeventhandler}
|
|
|
|
|
|
|
|
\membersection{wxEvtHandler::SetPreviousHandler}\label{wxevthandlersetprevioushandler}
|
|
|
|
|
|
|
|
\func{void}{SetPreviousHandler}{\param{wxEvtHandler* }{handler}}
|
|
|
|
|
|
|
|
Sets the pointer to the previous handler.
|
|
|
|
|
|
|
|
\wxheading{Parameters}
|
|
|
|
|
|
|
|
\docparam{handler}{Event handler to be set as the previous handler.}
|
|
|
|
|
|
|
|
\wxheading{See also}
|
|
|
|
|
|
|
|
\helpref{wxEvtHandler::GetPreviousHandler}{wxevthandlergetprevioushandler},\rtfsp
|
|
|
|
\helpref{wxEvtHandler::SetNextHandler}{wxevthandlersetnexthandler},\rtfsp
|
|
|
|
\helpref{wxEvtHandler::GetNextHandler}{wxevthandlergetnexthandler},\rtfsp
|
|
|
|
\helpref{wxWindow::PushEventHandler}{wxwindowpusheventhandler},\rtfsp
|
|
|
|
\helpref{wxWindow::PopEventHandler}{wxwindowpopeventhandler}
|
|
|
|
|
|
|
|
|