]> git.saurik.com Git - wxWidgets.git/blame_incremental - docs/latex/wx/event.tex
added wxMessageQueue class for inter-thread communications
[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{Library}
21
22\helpref{wxBase}{librarieslist}
23
24\wxheading{See also}
25
26\helpref{wxCommandEvent}{wxcommandevent},\rtfsp
27\helpref{wxMouseEvent}{wxmouseevent}
28
29\latexignore{\rtfignore{\wxheading{Members}}}
30
31
32\membersection{wxEvent::wxEvent}\label{wxeventctor}
33
34\func{}{wxEvent}{\param{int }{id = 0}, \param{wxEventType }{eventType = {\tt wxEVT\_NULL}}}
35
36Constructor. Should not need to be used directly by an application.
37
38
39\membersection{wxEvent::m\_propagationLevel}\label{wxeventmpropagationlevel}
40
41
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
50The initial value is set to either {\tt wxEVENT\_PROPAGATE\_NONE} (by
51default) meaning that the event shouldn't be propagated at all or to
52{\tt wxEVENT\_PROPAGATE\_MAX} (for command events) meaning that it should be
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
59
60\membersection{wxEvent::Clone}\label{wxeventclone}
61
62\constfunc{virtual wxEvent*}{Clone}{\void}
63
64Returns a copy of the event.
65
66Any event that is posted to the wxWidgets event system for later action (via
67\helpref{wxEvtHandler::AddPendingEvent}{wxevthandleraddpendingevent} or
68\helpref{wxPostEvent}{wxpostevent}) must implement this method. All wxWidgets
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
73All wxWidgets events implement a copy constructor, so the easiest way of
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:
76
77\begin{verbatim}
78 wxEvent *Clone(void) const { return new MyEvent(*this); }
79\end{verbatim}
80
81
82\membersection{wxEvent::GetEventObject}\label{wxeventgeteventobject}
83
84\func{wxObject*}{GetEventObject}{\void}
85
86Returns the object (usually a window) associated with the
87event, if any.
88
89
90\membersection{wxEvent::GetEventType}\label{wxeventgeteventtype}
91
92\func{wxEventType}{GetEventType}{\void}
93
94Returns the identifier of the given event type,
95such as \texttt{wxEVT\_COMMAND\_BUTTON\_CLICKED}.
96
97
98\membersection{wxEvent::GetId}\label{wxeventgetid}
99
100\constfunc{int}{GetId}{\void}
101
102Returns the identifier associated with this event, such as a button command id.
103
104
105\membersection{wxEvent::GetSkipped}\label{wxeventgetskipped}
106
107\constfunc{bool}{GetSkipped}{\void}
108
109Returns true if the event handler should be skipped, false otherwise.
110
111
112\membersection{wxEvent::GetTimestamp}\label{wxeventgettimestamp}
113
114\func{long}{GetTimestamp}{\void}
115
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
121
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
139\membersection{wxEvent::SetEventObject}\label{wxeventseteventobject}
140
141\func{void}{SetEventObject}{\param{wxObject* }{object}}
142
143Sets the originating object.
144
145
146\membersection{wxEvent::SetEventType}\label{wxeventseteventtype}
147
148\func{void}{SetEventType}{\param{wxEventType }{type}}
149
150Sets the event type.
151
152
153\membersection{wxEvent::SetId}\label{wxeventsetid}
154
155\func{void}{SetId}{\param{int}{ id}}
156
157Sets the identifier associated with this event, such as a button command id.
158
159
160\membersection{wxEvent::SetTimestamp}\label{wxeventsettimestamp}
161
162\func{void}{SetTimestamp}{\param{long }{timeStamp}}
163
164Sets the timestamp for the event.
165
166
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
174
175\membersection{wxEvent::Skip}\label{wxeventskip}
176
177\func{void}{Skip}{\param{bool}{ skip = true}}
178
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.
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.
190
191
192\membersection{wxEvent::StopPropagation}\label{wxeventstoppropagation}
193
194\func{int}{StopPropagation}{\void}
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