]> git.saurik.com Git - wxWidgets.git/blob - docs/latex/wx/event.tex
Added automatic dialog scrolling ability
[wxWidgets.git] / docs / latex / wx / event.tex
1 \section{\class{wxEvent}}\label{wxevent}
2
3 An event is a structure holding information about an event passed to a
4 callback or member function. {\bf wxEvent} used to be a multipurpose
5 event object, and is an abstract base class for other event classes (see below).
6
7 For 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
36 Constructor. 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
44 Indicates how many levels the event can propagate. This member is protected and
45 should typically only be set in the constructors of the derived classes. It
46 may be temporarily changed by \helpref{StopPropagation}{wxeventstoppropagation}
47 and \helpref{ResumePropagation}{wxeventresumepropagation} and tested with
48 \helpref{ShouldPropagate}{wxeventshouldpropagate}.
49
50 The initial value is set to either {\tt wxEVENT\_PROPAGATE\_NONE} (by
51 default) 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
53 propagated as much as necessary.
54
55 Any positive number means that the event should be propagated but no more than
56 the given number of times. E.g. the propagation level may be set to $1$ to
57 propagate 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
64 Returns a copy of the event.
65
66 Any 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
69 events fully implement this method, but any derived events implemented by the
70 user should also implement this method just in case they (or some event
71 derived from them) are ever posted.
72
73 All wxWidgets events implement a copy constructor, so the easiest way of
74 implementing the Clone function is to implement a copy constructor for
75 a 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
86 Returns the object (usually a window) associated with the
87 event, if any.
88
89
90 \membersection{wxEvent::GetEventType}\label{wxeventgeteventtype}
91
92 \func{wxEventType}{GetEventType}{\void}
93
94 Returns the identifier of the given event type,
95 such as \texttt{wxEVT\_COMMAND\_BUTTON\_CLICKED}.
96
97
98 \membersection{wxEvent::GetId}\label{wxeventgetid}
99
100 \constfunc{int}{GetId}{\void}
101
102 Returns 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
109 Returns 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
116 Gets the timestamp for the event. The timestamp is the time in milliseconds
117 since some fixed moment (\emph{not} necessarily the standard Unix Epoch, so
118 only differences between the timestamps and not their absolute values usually
119 make sense).
120
121
122 \membersection{wxEvent::IsCommandEvent}\label{wxeventiscommandevent}
123
124 \constfunc{bool}{IsCommandEvent}{\void}
125
126 Returns true if the event is or is derived from
127 \helpref{wxCommandEvent}{wxcommandevent} else it returns false.
128 Note: Exists only for optimization purposes.
129
130
131 \membersection{wxEvent::ResumePropagation}\label{wxeventresumepropagation}
132
133 \func{void}{ResumePropagation}{\param{int }{propagationLevel}}
134
135 Sets the propagation level to the given value (for example returned from an
136 earlier call to \helpref{StopPropagation}{wxeventstoppropagation}).
137
138
139 \membersection{wxEvent::SetEventObject}\label{wxeventseteventobject}
140
141 \func{void}{SetEventObject}{\param{wxObject* }{object}}
142
143 Sets the originating object.
144
145
146 \membersection{wxEvent::SetEventType}\label{wxeventseteventtype}
147
148 \func{void}{SetEventType}{\param{wxEventType }{type}}
149
150 Sets the event type.
151
152
153 \membersection{wxEvent::SetId}\label{wxeventsetid}
154
155 \func{void}{SetId}{\param{int}{ id}}
156
157 Sets 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
164 Sets the timestamp for the event.
165
166
167 \membersection{wxEvent::ShouldPropagate}\label{wxeventshouldpropagate}
168
169 \constfunc{bool}{ShouldPropagate}{\void}
170
171 Test if this event should be propagated or not, i.e. if the propagation level
172 is currently greater than $0$.
173
174
175 \membersection{wxEvent::Skip}\label{wxeventskip}
176
177 \func{void}{Skip}{\param{bool}{ skip = true}}
178
179 This method can be used inside an event handler to control whether further
180 event handlers bound to this event will be called after the current one
181 returns. Without Skip() (or equivalently if Skip(false) is used),
182 the event will not be processed any more. If Skip(true) is called, the event
183 processing system continues searching for a further handler function for this
184 event, even though it has been processed already in the current handler.
185
186 In general, it is recommended to skip all non-command events to allow the
187 default handling to take place. The command events are, however, normally not
188 skipped as usually a single command such as a button click or menu item
189 selection must only be processed by one handler.
190
191
192 \membersection{wxEvent::StopPropagation}\label{wxeventstoppropagation}
193
194 \func{int}{StopPropagation}{\void}
195
196 Stop the event from propagating to its parent window.
197
198 Returns the old propagation level value which may be later passed to
199 \helpref{ResumePropagation}{wxeventresumepropagation} to allow propagating the
200 event again.
201