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