]> git.saurik.com Git - wxWidgets.git/blame_incremental - docs/latex/wx/event.tex
another patch bring the docs more up to date (patch 1717776)
[wxWidgets.git] / docs / latex / wx / event.tex
... / ...
CommitLineData
1\section{\class{wxEvent}}\label{wxevent}
2
3An event is a structure holding information about an event passed to a
4callback or member function. {\bf wxEvent} used to be a multipurpose
5event object, and is an abstract base class for other event classes (see below).
6
7For more information about events, see the \helpref{Event handling overview}{eventhandlingoverview}.
8
9\perlnote{In wxPerl custom event classes should be derived from
10\texttt{Wx::PlEvent} and \texttt{Wx::PlCommandEvent}.}
11
12\wxheading{Derived from}
13
14\helpref{wxObject}{wxobject}
15
16\wxheading{Include files}
17
18<wx/event.h>
19
20\wxheading{See also}
21
22\helpref{wxCommandEvent}{wxcommandevent},\rtfsp
23\helpref{wxMouseEvent}{wxmouseevent}
24
25\latexignore{\rtfignore{\wxheading{Members}}}
26
27
28\membersection{wxEvent::wxEvent}\label{wxeventctor}
29
30\func{}{wxEvent}{\param{int }{id = 0}, \param{wxEventType }{eventType = {\tt wxEVT\_NULL}}}
31
32Constructor. Should not need to be used directly by an application.
33
34
35\membersection{wxEvent::m\_propagationLevel}\label{wxeventmpropagationlevel}
36
37
38\member{int}{m\_propagationLevel}
39
40Indicates how many levels the event can propagate. This member is protected and
41should typically only be set in the constructors of the derived classes. It
42may be temporarily changed by \helpref{StopPropagation}{wxeventstoppropagation}
43and \helpref{ResumePropagation}{wxeventresumepropagation} and tested with
44\helpref{ShouldPropagate}{wxeventshouldpropagate}.
45
46The initial value is set to either {\tt wxEVENT\_PROPAGATE\_NONE} (by
47default) meaning that the event shouldn't be propagated at all or to
48{\tt wxEVENT\_PROPAGATE\_MAX} (for command events) meaning that it should be
49propagated as much as necessary.
50
51Any positive number means that the event should be propagated but no more than
52the given number of times. E.g. the propagation level may be set to $1$ to
53propagate the event to its parent only, but not to its grandparent.
54
55
56\membersection{wxEvent::Clone}\label{wxeventclone}
57
58\constfunc{virtual wxEvent*}{Clone}{\void}
59
60Returns a copy of the event.
61
62Any event that is posted to the wxWidgets event system for later action (via
63\helpref{wxEvtHandler::AddPendingEvent}{wxevthandleraddpendingevent} or
64\helpref{wxPostEvent}{wxpostevent}) must implement this method. All wxWidgets
65events fully implement this method, but any derived events implemented by the
66user should also implement this method just in case they (or some event
67derived from them) are ever posted.
68
69All wxWidgets events implement a copy constructor, so the easiest way of
70implementing the Clone function is to implement a copy constructor for
71a new event (call it MyEvent) and then define the Clone function like this:
72
73\begin{verbatim}
74 wxEvent *Clone(void) const { return new MyEvent(*this); }
75\end{verbatim}
76
77
78\membersection{wxEvent::GetEventObject}\label{wxeventgeteventobject}
79
80\func{wxObject*}{GetEventObject}{\void}
81
82Returns the object (usually a window) associated with the
83event, if any.
84
85
86\membersection{wxEvent::GetEventType}\label{wxeventgeteventtype}
87
88\func{wxEventType}{GetEventType}{\void}
89
90Returns the identifier of the given event type,
91such as \texttt{wxEVT\_COMMAND\_BUTTON\_CLICKED}.
92
93
94\membersection{wxEvent::GetId}\label{wxeventgetid}
95
96\constfunc{int}{GetId}{\void}
97
98Returns the identifier associated with this event, such as a button command id.
99
100
101\membersection{wxEvent::GetSkipped}\label{wxeventgetskipped}
102
103\constfunc{bool}{GetSkipped}{\void}
104
105Returns true if the event handler should be skipped, false otherwise.
106
107
108\membersection{wxEvent::GetTimestamp}\label{wxeventgettimestamp}
109
110\func{long}{GetTimestamp}{\void}
111
112Gets the timestamp for the event. The timestamp is the time in milliseconds
113since some fixed moment (\emph{not} necessarily the standard Unix Epoch, so
114only differences between the timestamps and not their absolute values usually
115make sense).
116
117
118\membersection{wxEvent::IsCommandEvent}\label{wxeventiscommandevent}
119
120\constfunc{bool}{IsCommandEvent}{\void}
121
122Returns true if the event is or is derived from
123\helpref{wxCommandEvent}{wxcommandevent} else it returns false.
124Note: Exists only for optimization purposes.
125
126
127\membersection{wxEvent::ResumePropagation}\label{wxeventresumepropagation}
128
129\func{void}{ResumePropagation}{\param{int }{propagationLevel}}
130
131Sets the propagation level to the given value (for example returned from an
132earlier call to \helpref{StopPropagation}{wxeventstoppropagation}).
133
134
135\membersection{wxEvent::SetEventObject}\label{wxeventseteventobject}
136
137\func{void}{SetEventObject}{\param{wxObject* }{object}}
138
139Sets the originating object.
140
141
142\membersection{wxEvent::SetEventType}\label{wxeventseteventtype}
143
144\func{void}{SetEventType}{\param{wxEventType }{type}}
145
146Sets the event type.
147
148
149\membersection{wxEvent::SetId}\label{wxeventsetid}
150
151\func{void}{SetId}{\param{int}{ id}}
152
153Sets the identifier associated with this event, such as a button command id.
154
155
156\membersection{wxEvent::SetTimestamp}\label{wxeventsettimestamp}
157
158\func{void}{SetTimestamp}{\param{long }{timeStamp}}
159
160Sets the timestamp for the event.
161
162
163\membersection{wxEvent::ShouldPropagate}\label{wxeventshouldpropagate}
164
165\constfunc{bool}{ShouldPropagate}{\void}
166
167Test if this event should be propagated or not, i.e. if the propagation level
168is currently greater than $0$.
169
170
171\membersection{wxEvent::Skip}\label{wxeventskip}
172
173\func{void}{Skip}{\param{bool}{ skip = true}}
174
175This method can be used inside an event handler to control whether further
176event handlers bound to this event will be called after the current one
177returns. Without Skip() (or equivalently if Skip(false) is used),
178the event will not be processed any more. If Skip(true) is called, the event
179processing system continues searching for a further handler function for this
180event, even though it has been processed already in the current handler.
181
182In general, it is recommended to skip all non-command events to allow the
183default handling to take place. The command events are, however, normally not
184skipped as usually a single command such as a button click or menu item
185selection must only be processed by one handler.
186
187
188\membersection{wxEvent::StopPropagation}\label{wxeventstoppropagation}
189
190\func{int}{StopPropagation}{\void}
191
192Stop the event from propagating to its parent window.
193
194Returns the old propagation level value which may be later passed to
195\helpref{ResumePropagation}{wxeventresumepropagation} to allow propagating the
196event again.
197