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
}
11 \wxheading{Include files
}
17 \overview{Event handling overview
}{eventhandlingoverview
}
19 \latexignore{\rtfignore{\wxheading{Members
}}}
21 \membersection{wxEvtHandler::wxEvtHandler
}
23 \func{}{wxEvtHandler
}{\void}
27 \membersection{wxEvtHandler::
\destruct{wxEvtHandler
}}
29 \func{}{\destruct{wxEvtHandler
}}{\void}
31 Destructor. If the handler is part of a chain, the destructor will
32 unlink itself and restore the previous and next handlers so that they point to
35 \membersection{wxEvtHandler::Connect
}\label{wxevthandlerconnect
}
37 \func{void
}{Connect
}{\param{int
}{ id
},
38 \param{wxEventType
}{eventType
},
\param{wxObjectEventFunction
}{ function
},
39 \param{wxObject*
}{ userData = NULL
}}
41 \func{void
}{Connect
}{\param{int
}{ id
},
\param{int
}{ lastId
},
42 \param{wxEventType
}{eventType
},
\param{wxObjectEventFunction
}{ function
},
43 \param{wxObject*
}{ userData = NULL
}}
45 Connects the given function dynamically with the event handler, id and event type. This
46 is an alternative to the use of static event tables. See the 'dynamic' sample for usage.
48 \wxheading{Parameters
}
50 \docparam{id
}{The identifier (or first of the identifier range) to be associated with the event handler function.
}
52 \docparam{lastId
}{The second part of the identifier range to be associated with the event handler function.
}
54 \docparam{eventType
}{The event type to be associated with this event handler.
}
56 \docparam{function
}{The event handler function.
}
58 \docparam{userData
}{Data to be associated with the event table entry.
}
63 frame->Connect( wxID_EXIT,
64 wxEVT_COMMAND_MENU_SELECTED,
65 (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) MyFrame::OnQuit );
68 \membersection{wxEvtHandler::Default
}\label{wxevthandlerdefault
}
70 \func{virtual long
}{Default
}{\void}
72 Invokes default processing if this event handler is a window.
74 \wxheading{Return value
}
80 A generic way of delegating processing to the default system behaviour. It calls a platform-dependent
81 default function, with parameters dependent on the event or message parameters
82 originally sent from the windowing system.
84 Normally the application should call a base member, such as
\helpref{wxWindow::OnChar
}{wxwindowonchar
}, which itself
85 may call
{\bf Default
}.
87 \membersection{wxEvtHandler::GetClientData
}\label{wxevthandlergetclientdata
}
89 \func{char*
}{GetClientData
}{\void}
91 Gets user-supplied client data.
95 Normally, any extra data the programmer wishes to associate with the object
96 should be made available by deriving a new class
97 with new data members.
101 \helpref{wxEvtHandler::SetClientData
}{wxevthandlersetclientdata
}
103 \membersection{wxEvtHandler::GetEvtHandlerEnabled
}\label{wxevthandlergetevthandlerenabled
}
105 \func{bool
}{GetEvtHandlerEnabled
}{\void}
107 Returns TRUE if the event handler is enabled, FALSE otherwise.
111 \helpref{wxEvtHandler::SetEvtHandlerEnabled
}{wxevthandlersetevthandlerenabled
}
113 \membersection{wxEvtHandler::GetNextHandler
}\label{wxevthandlergetnexthandler
}
115 \func{wxEvtHandler*
}{GetNextHandler
}{\void}
117 Gets the pointer to the next handler in the chain.
121 \helpref{wxEvtHandler::GetPreviousHandler
}{wxevthandlergetprevioushandler
},
\rtfsp
122 \helpref{wxEvtHandler::SetPreviousHandler
}{wxevthandlersetprevioushandler
},
\rtfsp
123 \helpref{wxEvtHandler::SetNextHandler
}{wxevthandlersetnexthandler
},
\rtfsp
124 \helpref{wxWindow::PushEventHandler
}{wxwindowpusheventhandler
},
\rtfsp
125 \helpref{wxWindow::PopEventHandler
}{wxwindowpopeventhandler
}
127 \membersection{wxEvtHandler::GetPreviousHandler
}\label{wxevthandlergetprevioushandler
}
129 \func{wxEvtHandler*
}{GetPreviousHandler
}{\void}
131 Gets the pointer to the previous handler in the chain.
135 \helpref{wxEvtHandler::GetPreviousHandler
}{wxevthandlergetprevioushandler
},
\rtfsp
136 \helpref{wxEvtHandler::SetPreviousHandler
}{wxevthandlersetprevioushandler
},
\rtfsp
137 \helpref{wxEvtHandler::SetPreviousHandler
}{wxevthandlersetprevioushandler
},
\rtfsp
138 \helpref{wxWindow::PushEventHandler
}{wxwindowpusheventhandler
},
\rtfsp
139 \helpref{wxWindow::PopEventHandler
}{wxwindowpopeventhandler
}
141 \membersection{wxEvtHandler::ProcessEvent
}\label{wxevthandlerprocessevent
}
143 \func{virtual bool
}{ProcessEvent
}{\param{wxEvent\&
}{event
}}
145 Processes an event, searching event tables and calling zero or more suitable event handler function(s).
147 \wxheading{Parameters
}
149 \docparam{event
}{Event to process.
}
151 \wxheading{Return value
}
153 TRUE if a suitable event handler function was found and executed, and the function did not
154 call
\helpref{wxEvent::Skip
}{wxeventskip
}.
158 Normally, your application would not call this function: it is called in the wxWindows
159 implementation to dispatch incoming user interface events to the framework (and application).
161 However, you might need to call it if implementing new functionality (such as a new control) where
162 you define new event types, as opposed to allowing the user to override virtual functions.
164 An instance where you might actually override the
{\bf ProcessEvent
} function is where you want
165 to direct event processing to event handlers not normally noticed by wxWindows. For example,
166 in the
document/view architecture, documents and views are potential event handlers.
167 When an event reaches a frame,
{\bf ProcessEvent
} will need to be called on the associated
168 document and view in case event handler functions are associated with these objects.
169 The property classes library (wxProperty) also overrides
{\bf ProcessEvent
} for similar reasons.
171 The normal order of event table searching is as follows:
173 \begin{enumerate
}\itemsep=
0pt
174 \item If the object is disabled (via a call to
\helpref{wxEvtHandler::SetEvtHandlerEnabled
}{wxevthandlersetevthandlerenabled
})
175 the function skips to step (
6).
176 \item If the object is a wxWindow,
{\bf ProcessEvent
} is recursively called on the window's
\rtfsp
177 \helpref{wxValidator
}{wxvalidator
}. If this returns TRUE, the function exits.
178 \item {\bf SearchEventTable
} is called for this event handler. If this fails, the base
179 class table is tried, and so on until no more tables exist or an appropriate function was found,
180 in which case the function exits.
181 \item The search is applied down the entire chain of event handlers (usually the chain has a length
182 of one). If this succeeds, the function exits.
183 \item If the object is a wxWindow and the event is a wxCommandEvent,
{\bf ProcessEvent
} is
184 recursively applied to the parent window's event handler. If this returns TRUE, the function exits.
185 \item Finally,
{\bf ProcessEvent
} is called on the wxApp object.
190 \helpref{wxEvtHandler::SearchEventTable
}{wxevthandlersearcheventtable
}
192 \membersection{wxEvtHandler::SearchEventTable
}\label{wxevthandlersearcheventtable
}
194 \func{bool
}{SearchEventTable
}{\param{wxEventTable\&
}{table
},
\param{wxEvent\&
}{event
}}
196 Searches the event table, executing an event handler function if an appropriate one
199 \wxheading{Parameters
}
201 \docparam{table
}{Event table to be searched.
}
203 \docparam{event
}{Event to be matched against an event table entry.
}
205 \wxheading{Return value
}
207 TRUE if a suitable event handler function was found and executed, and the function did not
208 call
\helpref{wxEvent::Skip
}{wxeventskip
}.
212 This function looks through the object's event table and tries to find an entry
213 that will match the event.
215 An entry will match if:
217 \begin{enumerate
}\itemsep=
0pt
218 \item The event type matches, and
219 \item the identifier or identifier range matches, or the event table entry's identifier is zero.
222 If a suitable function is called but calls
\helpref{wxEvent::Skip
}{wxeventskip
}, this function will
223 fail, and searching will continue.
227 \helpref{wxEvtHandler::ProcessEvent
}{wxevthandlerprocessevent
}
229 \membersection{wxEvtHandler::SetClientData
}\label{wxevthandlersetclientdata
}
231 \func{void
}{SetClientData
}{\param{char*
}{data
}}
233 Sets user-supplied client data.
235 \wxheading{Parameters
}
237 \docparam{data
}{Data to be associated with the event handler.
}
241 Normally, any extra data the programmer wishes
242 to associate with the object should be made available by deriving a new class
243 with new data members.
244 %TODO: make this void*, char* only in compatibility mode.
248 \helpref{wxEvtHandler::GetClientData
}{wxevthandlergetclientdata
}
250 \membersection{wxEvtHandler::SetEvtHandlerEnabled
}\label{wxevthandlersetevthandlerenabled
}
252 \func{void
}{SetEvtHandlerEnabled
}{\param{bool
}{enabled
}}
254 Enables or disables the event handler.
256 \wxheading{Parameters
}
258 \docparam{enabled
}{TRUE if the event handler is to be enabled, FALSE if it is to be disabled.
}
262 You can use this function to avoid having to remove the event handler from the chain, for example
263 when implementing a dialog editor and changing from edit to test mode.
267 \helpref{wxEvtHandler::GetEvtHandlerEnabled
}{wxevthandlergetevthandlerenabled
}
269 \membersection{wxEvtHandler::SetNextHandler
}\label{wxevthandlersetnexthandler
}
271 \func{void
}{SetNextHandler
}{\param{wxEvtHandler*
}{handler
}}
273 Sets the pointer to the next handler.
275 \wxheading{Parameters
}
277 \docparam{handler
}{Event handler to be set as the next handler.
}
281 \helpref{wxEvtHandler::GetNextHandler
}{wxevthandlergetnexthandler
},
\rtfsp
282 \helpref{wxEvtHandler::SetPreviousHandler
}{wxevthandlersetprevioushandler
},
\rtfsp
283 \helpref{wxEvtHandler::GetPreviousHandler
}{wxevthandlergetprevioushandler
},
\rtfsp
284 \helpref{wxWindow::PushEventHandler
}{wxwindowpusheventhandler
},
\rtfsp
285 \helpref{wxWindow::PopEventHandler
}{wxwindowpopeventhandler
}
287 \membersection{wxEvtHandler::SetPreviousHandler
}\label{wxevthandlersetprevioushandler
}
289 \func{void
}{SetPreviousHandler
}{\param{wxEvtHandler*
}{handler
}}
291 Sets the pointer to the previous handler.
293 \wxheading{Parameters
}
295 \docparam{handler
}{Event handler to be set as the previous handler.
}
299 \helpref{wxEvtHandler::GetPreviousHandler
}{wxevthandlergetprevioushandler
},
\rtfsp
300 \helpref{wxEvtHandler::SetNextHandler
}{wxevthandlersetnexthandler
},
\rtfsp
301 \helpref{wxEvtHandler::GetNextHandler
}{wxevthandlergetnexthandler
},
\rtfsp
302 \helpref{wxWindow::PushEventHandler
}{wxwindowpusheventhandler
},
\rtfsp
303 \helpref{wxWindow::PopEventHandler
}{wxwindowpopeventhandler
}