evthand.tex
来自「Wxpython Implemented on Windows CE, Sou」· TEX 代码 · 共 399 行 · 第 1/2 页
TEX
399 行
\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.
When events are received, wxEvtHandler invokes the method listed in the
event table using itself as the object. When using multiple inheritance
it is imperative that the wxEvtHandler(-derived) class be the first
class inherited such that the "this" pointer for the overall object
will be identical to the "this" pointer for the wxEvtHandler portion.
\wxheading{Derived from}
\helpref{wxObject}{wxobject}
\wxheading{Include files}
<wx/event.h>
\wxheading{See also}
\overview{Event handling overview}{eventhandlingoverview}
\latexignore{\rtfignore{\wxheading{Members}}}
\membersection{wxEvtHandler::wxEvtHandler}\label{wxevthandlerctor}
\func{}{wxEvtHandler}{\void}
Constructor.
\membersection{wxEvtHandler::\destruct{wxEvtHandler}}\label{wxevthandlerdtor}
\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.
\membersection{wxEvtHandler::AddPendingEvent}\label{wxevthandleraddpendingevent}
\func{void}{AddPendingEvent}{\param{wxEvent\& }{event}}
This function posts an event to be processed later.
\wxheading{Parameters}
\docparam{event}{Event to add to process queue.}
\wxheading{Remarks}
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}.)
\membersection{wxEvtHandler::Connect}\label{wxevthandlerconnect}
\func{void}{Connect}{\param{int}{ id}, \param{int}{ lastId},
\param{wxEventType }{eventType}, \param{wxObjectEventFunction}{ function},
\param{wxObject*}{ userData = NULL}, \param{wxEvtHandler*}{ eventSink = NULL}}
\func{void}{Connect}{\param{int}{ id},
\param{wxEventType }{eventType}, \param{wxObjectEventFunction}{ function},
\param{wxObject*}{ userData = NULL}, \param{wxEvtHandler*}{ eventSink = NULL}}
\func{void}{Connect}{\param{wxEventType }{eventType}, \param{wxObjectEventFunction}{ function},
\param{wxObject*}{ userData = NULL}, \param{wxEvtHandler*}{ eventSink = 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 'event' or the old 'dynamic' sample for usage.
\wxheading{Parameters}
\docparam{id}{The identifier (or first of the identifier range) to be
associated with the event handler function. For the version not taking this
argument, it defaults to \texttt{wxID\_ANY}.}
\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. Note that this function should
be explicitly converted to the correct type which can be done using a macro
called \texttt{wxFooHandler} for the handler for any \texttt{wxFooEvent}.}
\docparam{userData}{Data to be associated with the event table entry.}
\docparam{eventSink}{Object whose member function should be called. If this is NULL,
\textit{this} will be used.}
\wxheading{Example}
\begin{verbatim}
frame->Connect( wxID_EXIT,
wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler(MyFrame::OnQuit) );
\end{verbatim}
\perlnote{In wxPerl this function takes 4 arguments: \texttt{id,
lastid, type, method}; if \texttt{method} is \texttt{undef}, the
handler is disconnected.}
\membersection{wxEvtHandler::Disconnect}\label{wxevthandlerdisconnect}
\func{bool}{Disconnect}{\param{wxEventType }{eventType = wxEVT\_NULL}, \param{wxObjectEventFunction}{ function = NULL},
\param{wxObject*}{ userData = NULL}, \param{wxEvtHandler*}{ eventSink = NULL}}
\func{bool}{Disconnect}{\param{int}{ id = \texttt{wxID\_ANY}},
\param{wxEventType }{eventType = wxEVT\_NULL}, \param{wxObjectEventFunction}{ function = NULL},
\param{wxObject*}{ userData = NULL}, \param{wxEvtHandler*}{ eventSink = NULL}}
\func{bool}{Disconnect}{\param{int}{ id}, \param{int}{ lastId = \texttt{wxID\_ANY}},
\param{wxEventType }{eventType = wxEVT\_NULL}, \param{wxObjectEventFunction}{ function = NULL},
\param{wxObject*}{ userData = NULL}, \param{wxEvtHandler*}{ eventSink = NULL}}
Disconnects the given function dynamically from the event handler, using the specified
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
using the \helpref{wxEvtHandler::Connect}{wxevthandlerconnect} method. There is no way
to disconnect functions connected using the (static) event tables.
\wxheading{Parameters}
\docparam{id}{The identifier (or first of the identifier range) associated with the event handler function.}
\docparam{lastId}{The second part of the identifier range associated with the event handler function.}
\docparam{eventType}{The event type associated with this event handler.}
\docparam{function}{The event handler function.}
\docparam{userData}{Data associated with the event table entry.}
\docparam{eventSink}{Object whose member function should be called.}
\perlnote{In wxPerl this function takes 3 arguments: \texttt{id,
lastid, type}.}
\membersection{wxEvtHandler::GetClientData}\label{wxevthandlergetclientdata}
\func{void* }{GetClientData}{\void}
Gets user-supplied client data.
\wxheading{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.
\wxheading{See also}
\helpref{wxEvtHandler::SetClientData}{wxevthandlersetclientdata}
\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}
\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}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?