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