1 \section{\class{wxEvtHandler
}}\label{wxevthandler
}
3 A class that can handle events from the windowing system.
4 wxWindow (and therefore all window classes) are derived from
7 \wxheading{Derived from
}
9 \helpref{wxObject
}{wxobject
}
13 \overview{Event handling overview
}{eventhandlingoverview
}
15 \latexignore{\rtfignore{\wxheading{Members
}}}
17 \membersection{wxEvtHandler::wxEvtHandler
}
19 \func{}{wxEvtHandler
}{\void}
23 \membersection{wxEvtHandler::
\destruct{wxEvtHandler
}}
25 \func{}{\destruct{wxEvtHandler
}}{\void}
27 Destructor. If the handler is part of a chain, the destructor will
28 unlink itself and restore the previous and next handlers so that they point to
31 \membersection{wxEvtHandler::Connect
}\label{wxevthandlerconnect
}
33 \func{void
}{Connect
}{\param{int
}{ id
},
34 \param{wxEventType
}{eventType
},
\param{wxObjectEventFunction
}{ function
},
35 \param{wxObject*
}{ userData = NULL
}}
37 \func{void
}{Connect
}{\param{int
}{ id
},
\param{int
}{ lastId
},
38 \param{wxEventType
}{eventType
},
\param{wxObjectEventFunction
}{ function
},
39 \param{wxObject*
}{ userData = NULL
}}
41 Connects the given function dynamically with the event handler, id and event type. This
42 is an alternative to the use of static event tables. See the 'dynamic' sample for usage.
44 \wxheading{Parameters
}
46 \docparam{id
}{The identifier (or first of the identifier range) to be associated with the event handler function.
}
48 \docparam{lastId
}{The second part of the identifier range to be associated with the event handler function.
}
50 \docparam{eventType
}{The event type to be associated with this event handler.
}
52 \docparam{function
}{The event handler function.
}
54 \docparam{userData
}{Data to be associated with the event table entry.
}
59 frame->Connect( wxID_EXIT,
60 wxEVT_COMMAND_MENU_SELECTED,
61 (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) MyFrame::OnQuit );
64 \membersection{wxEvtHandler::Default
}\label{wxevthandlerdefault
}
66 \func{virtual long
}{Default
}{\void}
68 Invokes default processing if this event handler is a window.
70 \wxheading{Return value
}
76 A generic way of delegating processing to the default system behaviour. It calls a platform-dependent
77 default function, with parameters dependent on the event or message parameters
78 originally sent from the windowing system.
80 Normally the application should call a base member, such as
\helpref{wxWindow::OnChar
}{wxwindowonchar
}, which itself
81 may call
{\bf Default
}.
83 \membersection{wxEvtHandler::GetClientData
}\label{wxevthandlergetclientdata
}
85 \func{char*
}{GetClientData
}{\void}
87 Gets user-supplied client data.
91 Normally, any extra data the programmer wishes to associate with the object
92 should be made available by deriving a new class
93 with new data members.
97 \helpref{wxEvtHandler::SetClientData
}{wxevthandlersetclientdata
}
99 \membersection{wxEvtHandler::GetEvtHandlerEnabled
}\label{wxevthandlergetevthandlerenabled
}
101 \func{bool
}{GetEvtHandlerEnabled
}{\void}
103 Returns TRUE if the event handler is enabled, FALSE otherwise.
107 \helpref{wxEvtHandler::SetEvtHandlerEnabled
}{wxevthandlersetevthandlerenabled
}
109 \membersection{wxEvtHandler::GetNextHandler
}\label{wxevthandlergetnexthandler
}
111 \func{wxEvtHandler*
}{GetNextHandler
}{\void}
113 Gets the pointer to the next handler in the chain.
117 \helpref{wxEvtHandler::GetPreviousHandler
}{wxevthandlergetprevioushandler
},
\rtfsp
118 \helpref{wxEvtHandler::SetPreviousHandler
}{wxevthandlersetprevioushandler
},
\rtfsp
119 \helpref{wxEvtHandler::SetNextHandler
}{wxevthandlersetnexthandler
},
\rtfsp
120 \helpref{wxWindow::PushEventHandler
}{wxwindowpusheventhandler
},
\rtfsp
121 \helpref{wxWindow::PopEventHandler
}{wxwindowpopeventhandler
}
123 \membersection{wxEvtHandler::GetPreviousHandler
}\label{wxevthandlergetprevioushandler
}
125 \func{wxEvtHandler*
}{GetPreviousHandler
}{\void}
127 Gets the pointer to the previous handler in the chain.
131 \helpref{wxEvtHandler::GetPreviousHandler
}{wxevthandlergetprevioushandler
},
\rtfsp
132 \helpref{wxEvtHandler::SetPreviousHandler
}{wxevthandlersetprevioushandler
},
\rtfsp
133 \helpref{wxEvtHandler::SetPreviousHandler
}{wxevthandlersetprevioushandler
},
\rtfsp
134 \helpref{wxWindow::PushEventHandler
}{wxwindowpusheventhandler
},
\rtfsp
135 \helpref{wxWindow::PopEventHandler
}{wxwindowpopeventhandler
}
137 \membersection{wxEvtHandler::ProcessEvent
}\label{wxevthandlerprocessevent
}
139 \func{virtual bool
}{ProcessEvent
}{\param{wxEvent\&
}{event
}}
141 Processes an event, searching event tables and calling zero or more suitable event handler function(s).
143 \wxheading{Parameters
}
145 \docparam{event
}{Event to process.
}
147 \wxheading{Return value
}
149 TRUE if a suitable event handler function was found and executed, and the function did not
150 call
\helpref{wxEvent::Skip
}{wxeventskip
}.
154 Normally, your application would not call this function: it is called in the wxWindows
155 implementation to dispatch incoming user interface events to the framework (and application).
157 However, you might need to call it if implementing new functionality (such as a new control) where
158 you define new event types, as opposed to allowing the user to override virtual functions.
160 An instance where you might actually override the
{\bf ProcessEvent
} function is where you want
161 to direct event processing to event handlers not normally noticed by wxWindows. For example,
162 in the
document/view architecture, documents and views are potential event handlers.
163 When an event reaches a frame,
{\bf ProcessEvent
} will need to be called on the associated
164 document and view in case event handler functions are associated with these objects.
165 The property classes library (wxProperty) also overrides
{\bf ProcessEvent
} for similar reasons.
167 The normal order of event table searching is as follows:
169 \begin{enumerate
}\itemsep=
0pt
170 \item If the object is disabled (via a call to
\helpref{wxEvtHandler::SetEvtHandlerEnabled
}{wxevthandlersetevthandlerenabled
})
171 the function skips to step (
6).
172 \item If the object is a wxWindow,
{\bf ProcessEvent
} is recursively called on the window's
\rtfsp
173 \helpref{wxValidator
}{wxvalidator
}. If this returns TRUE, the function exits.
174 \item {\bf SearchEventTable
} is called for this event handler. If this fails, the base
175 class table is tried, and so on until no more tables exist or an appropriate function was found,
176 in which case the function exits.
177 \item The search is applied down the entire chain of event handlers (usually the chain has a length
178 of one). If this succeeds, the function exits.
179 \item If the object is a wxWindow and the event is a wxCommandEvent,
{\bf ProcessEvent
} is
180 recursively applied to the parent window's event handler. If this returns TRUE, the function exits.
181 \item Finally,
{\bf ProcessEvent
} is called on the wxApp object.
186 \helpref{wxEvtHandler::SearchEventTable
}{wxevthandlersearcheventtable
}
188 \membersection{wxEvtHandler::SearchEventTable
}\label{wxevthandlersearcheventtable
}
190 \func{bool
}{SearchEventTable
}{\param{wxEventTable\&
}{table
},
\param{wxEvent\&
}{event
}}
192 Searches the event table, executing an event handler function if an appropriate one
195 \wxheading{Parameters
}
197 \docparam{table
}{Event table to be searched.
}
199 \docparam{event
}{Event to be matched against an event table entry.
}
201 \wxheading{Return value
}
203 TRUE if a suitable event handler function was found and executed, and the function did not
204 call
\helpref{wxEvent::Skip
}{wxeventskip
}.
208 This function looks through the object's event table and tries to find an entry
209 that will match the event.
211 An entry will match if:
213 \begin{enumerate
}\itemsep=
0pt
214 \item The event type matches, and
215 \item the identifier or identifier range matches, or the event table entry's identifier is zero.
218 If a suitable function is called but calls
\helpref{wxEvent::Skip
}{wxeventskip
}, this function will
219 fail, and searching will continue.
223 \helpref{wxEvtHandler::ProcessEvent
}{wxevthandlerprocessevent
}
225 \membersection{wxEvtHandler::SetClientData
}\label{wxevthandlersetclientdata
}
227 \func{void
}{SetClientData
}{\param{char*
}{data
}}
229 Sets user-supplied client data.
231 \wxheading{Parameters
}
233 \docparam{data
}{Data to be associated with the event handler.
}
237 Normally, any extra data the programmer wishes
238 to associate with the object should be made available by deriving a new class
239 with new data members.
240 %TODO: make this void*, char* only in compatibility mode.
244 \helpref{wxEvtHandler::GetClientData
}{wxevthandlergetclientdata
}
246 \membersection{wxEvtHandler::SetEvtHandlerEnabled
}\label{wxevthandlersetevthandlerenabled
}
248 \func{void
}{SetEvtHandlerEnabled
}{\param{bool
}{enabled
}}
250 Enables or disables the event handler.
252 \wxheading{Parameters
}
254 \docparam{enabled
}{TRUE if the event handler is to be enabled, FALSE if it is to be disabled.
}
258 You can use this function to avoid having to remove the event handler from the chain, for example
259 when implementing a dialog editor and changing from edit to test mode.
263 \helpref{wxEvtHandler::GetEvtHandlerEnabled
}{wxevthandlergetevthandlerenabled
}
265 \membersection{wxEvtHandler::SetNextHandler
}\label{wxevthandlersetnexthandler
}
267 \func{void
}{SetNextHandler
}{\param{wxEvtHandler*
}{handler
}}
269 Sets the pointer to the next handler.
271 \wxheading{Parameters
}
273 \docparam{handler
}{Event handler to be set as the next handler.
}
277 \helpref{wxEvtHandler::GetNextHandler
}{wxevthandlergetnexthandler
},
\rtfsp
278 \helpref{wxEvtHandler::SetPreviousHandler
}{wxevthandlersetprevioushandler
},
\rtfsp
279 \helpref{wxEvtHandler::GetPreviousHandler
}{wxevthandlergetprevioushandler
},
\rtfsp
280 \helpref{wxWindow::PushEventHandler
}{wxwindowpusheventhandler
},
\rtfsp
281 \helpref{wxWindow::PopEventHandler
}{wxwindowpopeventhandler
}
283 \membersection{wxEvtHandler::SetPreviousHandler
}\label{wxevthandlersetprevioushandler
}
285 \func{void
}{SetPreviousHandler
}{\param{wxEvtHandler*
}{handler
}}
287 Sets the pointer to the previous handler.
289 \wxheading{Parameters
}
291 \docparam{handler
}{Event handler to be set as the previous handler.
}
295 \helpref{wxEvtHandler::GetPreviousHandler
}{wxevthandlergetprevioushandler
},
\rtfsp
296 \helpref{wxEvtHandler::SetNextHandler
}{wxevthandlersetnexthandler
},
\rtfsp
297 \helpref{wxEvtHandler::GetNextHandler
}{wxevthandlergetnexthandler
},
\rtfsp
298 \helpref{wxWindow::PushEventHandler
}{wxwindowpusheventhandler
},
\rtfsp
299 \helpref{wxWindow::PopEventHandler
}{wxwindowpopeventhandler
}