]>
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 | ||
066f177c MB |
9 | \perlnote{In wxPerl custome event classes should be derived from |
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 | ||
27 | \membersection{wxEvent::wxEvent} | |
28 | ||
d5f648a9 | 29 | \func{}{wxEvent}{\param{int }{id = 0}, \param{wxEventType }{eventType = {\tt wxEVT\_NULL}}} |
a660d684 KB |
30 | |
31 | Constructor. Should not need to be used directly by an application. | |
32 | ||
a660d684 KB |
33 | \membersection{wxEvent::m\_eventObject} |
34 | ||
35 | \member{wxObject*}{m\_eventObject} | |
36 | ||
37 | The object (usually a window) that the event was generated from, | |
38 | or should be sent to. | |
39 | ||
40 | \membersection{wxEvent::m\_eventType} | |
41 | ||
42 | \member{WXTYPE}{m\_eventType} | |
43 | ||
44 | The type of the event, such as wxEVENT\_TYPE\_BUTTON\_COMMAND. | |
45 | ||
46 | \membersection{wxEvent::m\_id} | |
47 | ||
48 | \member{int}{m\_id} | |
49 | ||
50 | Identifier for the window. | |
51 | ||
1648d51b VZ |
52 | \membersection{wxEvent::m\_propagationLevel} |
53 | ||
54 | \member{int}{m\_propagationLevel} | |
55 | ||
56 | Indicates how many levels the event can propagate. This member is protected and | |
57 | should typically only be set in the constructors of the derived classes. It | |
58 | may be temporarily changed by \helpref{StopPropagation}{wxeventstoppropagation} | |
59 | and \helpref{ResumePropagation}{wxeventresumepropagation} and tested with | |
60 | \helpref{ShouldPropagate}{wxeventshouldpropagate}. | |
61 | ||
26b6f3d3 | 62 | The initial value is set to either {\tt wxEVENT\_PROPAGATE\_NONE} (by |
1648d51b | 63 | default) meaning that the event shouldn't be propagated at all or to |
26b6f3d3 | 64 | {\tt wxEVENT\_PROPAGATE\_MAX} (for command events) meaning that it should be |
1648d51b VZ |
65 | propagated as much as necessary. |
66 | ||
67 | Any positive number means that the event should be propagated but no more than | |
68 | the given number of times. E.g. the propagation level may be set to $1$ to | |
69 | propagate the event to its parent only, but not to its grandparent. | |
70 | ||
a660d684 KB |
71 | \membersection{wxEvent::m\_skipped} |
72 | ||
73 | \member{bool}{m\_skipped} | |
74 | ||
cc81d32f | 75 | Set to true by {\bf Skip} if this event should be skipped. |
a660d684 KB |
76 | |
77 | \membersection{wxEvent::m\_timeStamp} | |
78 | ||
79 | \member{long}{m\_timeStamp} | |
80 | ||
81 | Timestamp for this event. | |
82 | ||
8e72b8b5 RR |
83 | \membersection{wxEvent::Clone}\label{wxeventclone} |
84 | ||
d5f648a9 | 85 | \constfunc{virtual wxEvent*}{Clone}{\void} |
8e72b8b5 RR |
86 | |
87 | Returns a copy of the event. | |
88 | ||
fc2171bd | 89 | Any event that is posted to the wxWidgets event system for later action (via |
8e72b8b5 | 90 | \helpref{wxEvtHandler::AddPendingEvent}{wxevthandleraddpendingevent} or |
fc2171bd | 91 | \helpref{wxPostEvent}{wxpostevent}) must implement this method. All wxWidgets |
8e72b8b5 RR |
92 | events fully implement this method, but any derived events implemented by the |
93 | user should also implement this method just in case they (or some event | |
94 | derived from them) are ever posted. | |
95 | ||
fc2171bd | 96 | All wxWidgets events implement a copy constructor, so the easiest way of |
8e72b8b5 RR |
97 | implementing the Clone function is to implement a copy constructor for |
98 | a new event (call it MyEvent) and then define the Clone function like this: | |
d2c2afc9 | 99 | |
8e72b8b5 RR |
100 | \begin{verbatim} |
101 | wxEvent *Clone(void) const { return new MyEvent(*this); } | |
102 | \end{verbatim} | |
103 | ||
a660d684 KB |
104 | \membersection{wxEvent::GetEventObject} |
105 | ||
106 | \func{wxObject*}{GetEventObject}{\void} | |
107 | ||
108 | Returns the object associated with the | |
109 | event, if any. | |
110 | ||
111 | \membersection{wxEvent::GetEventType} | |
112 | ||
113 | \func{WXTYPE}{GetEventType}{\void} | |
114 | ||
115 | Returns the identifier of the given event type, | |
116 | such as wxEVENT\_TYPE\_BUTTON\_COMMAND. | |
117 | ||
118 | \membersection{wxEvent::GetId} | |
119 | ||
1648d51b | 120 | \constfunc{int}{GetId}{\void} |
a660d684 KB |
121 | |
122 | Returns the identifier associated with this event, such as a button command id. | |
123 | ||
a660d684 KB |
124 | \membersection{wxEvent::GetSkipped} |
125 | ||
1648d51b | 126 | \constfunc{bool}{GetSkipped}{\void} |
a660d684 | 127 | |
cc81d32f | 128 | Returns true if the event handler should be skipped, false otherwise. |
a660d684 KB |
129 | |
130 | \membersection{wxEvent::GetTimestamp} | |
131 | ||
132 | \func{long}{GetTimestamp}{\void} | |
133 | ||
134 | Gets the timestamp for the event. | |
135 | ||
1648d51b VZ |
136 | \membersection{wxEvent::IsCommandEvent}\label{wxeventiscommandevent} |
137 | ||
138 | \constfunc{bool}{IsCommandEvent}{\void} | |
139 | ||
140 | Returns true if the event is or is derived from | |
141 | \helpref{wxCommandEvent}{wxcommandevent} else it returns false. | |
142 | Note: Exists only for optimization purposes. | |
143 | ||
144 | ||
145 | \membersection{wxEvent::ResumePropagation}\label{wxeventresumepropagation} | |
146 | ||
147 | \func{void}{ResumePropagation}{\param{int }{propagationLevel}} | |
148 | ||
149 | Sets the propagation level to the given value (for example returned from an | |
150 | earlier call to \helpref{StopPropagation}{wxeventstoppropagation}). | |
151 | ||
152 | ||
a660d684 KB |
153 | \membersection{wxEvent::SetEventObject} |
154 | ||
155 | \func{void}{SetEventObject}{\param{wxObject* }{object}} | |
156 | ||
157 | Sets the originating object. | |
158 | ||
159 | \membersection{wxEvent::SetEventType} | |
160 | ||
161 | \func{void}{SetEventType}{\param{WXTYPE }{typ}} | |
162 | ||
163 | Sets the event type. | |
164 | ||
165 | \membersection{wxEvent::SetId} | |
166 | ||
167 | \func{void}{SetId}{\param{int}{ id}} | |
168 | ||
169 | Sets the identifier associated with this event, such as a button command id. | |
170 | ||
171 | \membersection{wxEvent::SetTimestamp} | |
172 | ||
173 | \func{void}{SetTimestamp}{\param{long }{timeStamp}} | |
174 | ||
175 | Sets the timestamp for the event. | |
176 | ||
177 | Sets the originating object. | |
178 | ||
1648d51b VZ |
179 | \membersection{wxEvent::ShouldPropagate}\label{wxeventshouldpropagate} |
180 | ||
181 | \constfunc{bool}{ShouldPropagate}{\void} | |
182 | ||
183 | Test if this event should be propagated or not, i.e. if the propagation level | |
184 | is currently greater than $0$. | |
185 | ||
a660d684 KB |
186 | \membersection{wxEvent::Skip}\label{wxeventskip} |
187 | ||
cc81d32f | 188 | \func{void}{Skip}{\param{bool}{ skip = true}} |
a660d684 KB |
189 | |
190 | Called by an event handler to tell the event system that the | |
191 | event handler should be skipped, and the next valid handler used | |
192 | instead. | |
193 | ||
684761db | 194 | \membersection{wxEvent::StopPropagation}\label{wxeventstoppropagation} |
1648d51b | 195 | |
684761db | 196 | \func{int}{StopPropagation}{\void} |
1648d51b VZ |
197 | |
198 | Stop the event from propagating to its parent window. | |
199 | ||
200 | Returns the old propagation level value which may be later passed to | |
201 | \helpref{ResumePropagation}{wxeventresumepropagation} to allow propagating the | |
202 | event again. | |
203 |