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