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