]>
Commit | Line | Data |
---|---|---|
a660d684 KB |
1 | \section{\class{wxCommandEvent}}\label{wxcommandevent} |
2 | ||
3 | This event class contains information about command events, which originate from a variety of | |
4 | simple controls. More complex controls, such as \helpref{wxTreeCtrl}{wxtreectrl}, have separate command event classes. | |
5 | ||
6 | \wxheading{Derived from} | |
7 | ||
8 | \helpref{wxEvent}{wxevent} | |
9 | ||
954b8ae6 JS |
10 | \wxheading{Include files} |
11 | ||
12 | <wx/event.h> | |
13 | ||
a7af285d VZ |
14 | \wxheading{Library} |
15 | ||
16 | \helpref{wxCore}{librarieslist} | |
17 | ||
a660d684 KB |
18 | \wxheading{Event table macros} |
19 | ||
20 | To process a menu command event, use these event handler macros to direct input to member | |
21 | functions that take a wxCommandEvent argument. | |
22 | ||
23 | \twocolwidtha{7cm} | |
24 | \begin{twocollist}\itemsep=0pt | |
1f112209 | 25 | \twocolitem{{\bf EVT\_COMMAND(id, event, func)}}{Process a command, supplying the window identifier, |
a660d684 | 26 | command event identifier, and member function.} |
1f112209 | 27 | \twocolitem{{\bf EVT\_COMMAND\_RANGE(id1, id2, event, func)}}{Process a command for a range |
a660d684 KB |
28 | of window identifiers, supplying the minimum and maximum window identifiers, |
29 | command event identifier, and member function.} | |
30 | \twocolitem{{\bf EVT\_BUTTON(id, func)}}{Process a wxEVT\_COMMAND\_BUTTON\_CLICKED command, | |
31 | which is generated by a wxButton control.} | |
32 | \twocolitem{{\bf EVT\_CHECKBOX(id, func)}}{Process a wxEVT\_COMMAND\_CHECKBOX\_CLICKED command, | |
33 | which is generated by a wxCheckBox control.} | |
34 | \twocolitem{{\bf EVT\_CHOICE(id, func)}}{Process a wxEVT\_COMMAND\_CHOICE\_SELECTED command, | |
35 | which is generated by a wxChoice control.} | |
052d2fc5 KH |
36 | \twocolitem{{\bf EVT\_COMBOBOX(id, func)}}{Process a wxEVT\_COMMAND\_COMBOBOX\_SELECTED command, |
37 | which is generated by a wxComboBox control.} | |
a660d684 KB |
38 | \twocolitem{{\bf EVT\_LISTBOX(id, func)}}{Process a wxEVT\_COMMAND\_LISTBOX\_SELECTED command, |
39 | which is generated by a wxListBox control.} | |
e14dccff | 40 | \twocolitem{{\bf EVT\_LISTBOX\_DCLICK(id, func)}}{Process a wxEVT\_COMMAND\_LISTBOX\_DOUBLECLICKED command, |
debe6624 | 41 | which is generated by a wxListBox control.} |
a660d684 KB |
42 | \twocolitem{{\bf EVT\_MENU(id, func)}}{Process a wxEVT\_COMMAND\_MENU\_SELECTED command, |
43 | which is generated by a menu item.} | |
44 | \twocolitem{{\bf EVT\_MENU\_RANGE(id1, id2, func)}}{Process a wxEVT\_COMMAND\_MENU\_RANGE command, | |
45 | which is generated by a range of menu items.} | |
ccef86c7 VZ |
46 | \twocolitem{{\bf EVT\_CONTEXT\_MENU(func)}}{Process the event generated |
47 | when the user has requested a popup menu to appear by pressing a special | |
48 | keyboard key (under Windows) or by right clicking the mouse.} | |
a660d684 KB |
49 | \twocolitem{{\bf EVT\_RADIOBOX(id, func)}}{Process a wxEVT\_COMMAND\_RADIOBOX\_SELECTED command, |
50 | which is generated by a wxRadioBox control.} | |
51 | \twocolitem{{\bf EVT\_RADIOBUTTON(id, func)}}{Process a wxEVT\_COMMAND\_RADIOBUTTON\_SELECTED command, | |
52 | which is generated by a wxRadioButton control.} | |
53 | \twocolitem{{\bf EVT\_SCROLLBAR(id, func)}}{Process a wxEVT\_COMMAND\_SCROLLBAR\_UPDATED command, | |
54 | which is generated by a wxScrollBar control. This is provided for compatibility only; | |
55 | more specific scrollbar event macros should be used instead (see \helpref{wxScrollEvent}{wxscrollevent}).} | |
052d2fc5 KH |
56 | \twocolitem{{\bf EVT\_SLIDER(id, func)}}{Process a wxEVT\_COMMAND\_SLIDER\_UPDATED command, |
57 | which is generated by a wxSlider control.} | |
58 | \twocolitem{{\bf EVT\_TEXT(id, func)}}{Process a wxEVT\_COMMAND\_TEXT\_UPDATED command, | |
59 | which is generated by a wxTextCtrl control.} | |
60 | \twocolitem{{\bf EVT\_TEXT\_ENTER(id, func)}}{Process a wxEVT\_COMMAND\_TEXT\_ENTER command, | |
61 | which is generated by a wxTextCtrl control. Note that you must use | |
62 | wxTE\_PROCESS\_ENTER flag when creating the control if you want it to generate | |
63 | such events.} | |
64 | \twocolitem{{\bf EVT\_TEXT\_MAXLEN(id, func)}}{Process a wxEVT\_COMMAND\_TEXT\_MAXLEN command, | |
65 | which is generated by a wxTextCtrl control when the user tries to enter more | |
66 | characters into it than the limit previously set with | |
67 | \helpref{SetMaxLength}{wxtextctrlsetmaxlength}.} | |
20f82e13 | 68 | \twocolitem{{\bf EVT\_TOGGLEBUTTON(id, func)}}{Process a wxEVT\_COMMAND\_TOGGLEBUTTON\_CLICKED event.} |
81d66cf3 JS |
69 | \twocolitem{{\bf EVT\_TOOL(id, func)}}{Process a wxEVT\_COMMAND\_TOOL\_CLICKED event |
70 | (a synonym for wxEVT\_COMMAND\_MENU\_SELECTED). Pass the id of the tool.} | |
71 | \twocolitem{{\bf EVT\_TOOL\_RANGE(id1, id2, func)}}{Process a wxEVT\_COMMAND\_TOOL\_CLICKED event | |
156194e1 | 72 | for a range of identifiers. Pass the ids of the tools.} |
81d66cf3 JS |
73 | \twocolitem{{\bf EVT\_TOOL\_RCLICKED(id, func)}}{Process a wxEVT\_COMMAND\_TOOL\_RCLICKED event. |
74 | Pass the id of the tool.} | |
75 | \twocolitem{{\bf EVT\_TOOL\_RCLICKED\_RANGE(id1, id2, func)}}{Process a wxEVT\_COMMAND\_TOOL\_RCLICKED event | |
76 | for a range of ids. Pass the ids of the tools.} | |
77 | \twocolitem{{\bf EVT\_TOOL\_ENTER(id, func)}}{Process a wxEVT\_COMMAND\_TOOL\_ENTER event. | |
78 | Pass the id of the toolbar itself. The value of wxCommandEvent::GetSelection is the tool id, or -1 if the mouse cursor has moved off a tool.} | |
a660d684 KB |
79 | \twocolitem{{\bf EVT\_COMMAND\_LEFT\_CLICK(id, func)}}{Process a wxEVT\_COMMAND\_LEFT\_CLICK command, |
80 | which is generated by a control (Windows 95 and NT only).} | |
81 | \twocolitem{{\bf EVT\_COMMAND\_LEFT\_DCLICK(id, func)}}{Process a wxEVT\_COMMAND\_LEFT\_DCLICK command, | |
82 | which is generated by a control (Windows 95 and NT only).} | |
83 | \twocolitem{{\bf EVT\_COMMAND\_RIGHT\_CLICK(id, func)}}{Process a wxEVT\_COMMAND\_RIGHT\_CLICK command, | |
84 | which is generated by a control (Windows 95 and NT only).} | |
85 | \twocolitem{{\bf EVT\_COMMAND\_SET\_FOCUS(id, func)}}{Process a wxEVT\_COMMAND\_SET\_FOCUS command, | |
86 | which is generated by a control (Windows 95 and NT only).} | |
87 | \twocolitem{{\bf EVT\_COMMAND\_KILL\_FOCUS(id, func)}}{Process a wxEVT\_COMMAND\_KILL\_FOCUS command, | |
88 | which is generated by a control (Windows 95 and NT only).} | |
89 | \twocolitem{{\bf EVT\_COMMAND\_ENTER(id, func)}}{Process a wxEVT\_COMMAND\_ENTER command, | |
90 | which is generated by a control.} | |
91 | \end{twocollist}% | |
92 | ||
93 | \latexignore{\rtfignore{\wxheading{Members}}} | |
94 | ||
f510b7b2 | 95 | \membersection{wxCommandEvent::wxCommandEvent}\label{wxcommandeventctor} |
a660d684 KB |
96 | |
97 | \func{}{wxCommandEvent}{\param{WXTYPE}{ commandEventType = 0}, \param{int}{ id = 0}} | |
98 | ||
99 | Constructor. | |
100 | ||
f510b7b2 | 101 | \membersection{wxCommandEvent::Checked}\label{wxcommandeventchecked} |
a660d684 | 102 | |
3ca6a5f0 | 103 | \constfunc{bool}{Checked}{\void} |
a660d684 | 104 | |
3ca6a5f0 | 105 | Deprecated, use \helpref{IsChecked}{wxcommandeventischecked} instead. |
a660d684 | 106 | |
f510b7b2 | 107 | \membersection{wxCommandEvent::GetClientData}\label{wxcommandeventgetclientdata} |
a660d684 | 108 | |
9c884972 | 109 | \func{void*}{GetClientData}{\void} |
a660d684 KB |
110 | |
111 | Returns client data pointer for a listbox or choice selection event | |
3ca6a5f0 | 112 | (not valid for a deselection). |
a660d684 | 113 | |
f510b7b2 | 114 | \membersection{wxCommandEvent::GetClientObject}\label{wxcommandeventgetclientobject} |
88eadcf2 VZ |
115 | |
116 | \func{wxClientData *}{GetClientObject}{\void} | |
117 | ||
118 | Returns client object pointer for a listbox or choice selection event | |
119 | (not valid for a deselection). | |
120 | ||
f510b7b2 | 121 | \membersection{wxCommandEvent::GetExtraLong}\label{wxcommandeventgetextralong} |
a660d684 KB |
122 | |
123 | \func{long}{GetExtraLong}{\void} | |
124 | ||
1e75cc48 KH |
125 | Returns extra information dependant on the event objects type. |
126 | If the event comes from a listbox selection, it is a boolean | |
127 | determining whether the event was a selection (true) or a | |
128 | deselection (false). A listbox deselection only occurs for | |
129 | multiple-selection boxes, and in this case the index and string values | |
130 | are indeterminate and the listbox must be examined by the application. | |
a660d684 | 131 | |
f510b7b2 | 132 | \membersection{wxCommandEvent::GetInt}\label{wxcommandeventgetint} |
a660d684 KB |
133 | |
134 | \func{int}{GetInt}{\void} | |
135 | ||
1e75cc48 KH |
136 | Returns the integer identifier corresponding to a listbox, choice or |
137 | radiobox selection (only if the event was a selection, not a | |
138 | deselection), or a boolean value representing the value of a checkbox. | |
a660d684 | 139 | |
f510b7b2 | 140 | \membersection{wxCommandEvent::GetSelection}\label{wxcommandeventgetselection} |
a660d684 KB |
141 | |
142 | \func{int}{GetSelection}{\void} | |
143 | ||
144 | Returns item index for a listbox or choice selection event (not valid for | |
145 | a deselection). | |
146 | ||
f510b7b2 | 147 | \membersection{wxCommandEvent::GetString}\label{wxcommandeventgetstring} |
a660d684 | 148 | |
ce788ad9 | 149 | \func{wxString}{GetString}{\void} |
a660d684 KB |
150 | |
151 | Returns item string for a listbox or choice selection event (not valid for | |
152 | a deselection). | |
153 | ||
3ca6a5f0 BP |
154 | \membersection{wxCommandEvent::IsChecked}\label{wxcommandeventischecked} |
155 | ||
156 | \constfunc{bool}{IsChecked}{\void} | |
157 | ||
158 | This method can be used with checkbox and menu events: for the checkboxes, the | |
cc81d32f | 159 | method returns {\tt true} for a selection event and {\tt false} for a |
3ca6a5f0 BP |
160 | deselection one. For the menu events, this method indicates if the menu item |
161 | just has become checked or unchecked (and thus only makes sense for checkable | |
162 | menu items). | |
163 | ||
f510b7b2 | 164 | \membersection{wxCommandEvent::IsSelection}\label{wxcommandeventisselection} |
a660d684 KB |
165 | |
166 | \func{bool}{IsSelection}{\void} | |
167 | ||
9fa1a107 | 168 | For a listbox or similar event, returns true if it is a selection, false if it |
a660d684 KB |
169 | is a deselection. |
170 | ||
f510b7b2 | 171 | \membersection{wxCommandEvent::SetClientData}\label{wxcommandeventsetclientdata} |
a660d684 | 172 | |
9c884972 | 173 | \func{void}{SetClientData}{\param{void*}{ clientData}} |
a660d684 KB |
174 | |
175 | Sets the client data for this event. | |
176 | ||
f510b7b2 | 177 | \membersection{wxCommandEvent::SetClientObject}\label{wxcommandeventsetclientobject} |
88eadcf2 VZ |
178 | |
179 | \func{void}{SetClientObject}{\param{wxClientData*}{ clientObject}} | |
180 | ||
181 | Sets the client object for this event. The client object is \emph{not} owned by the event | |
182 | object and the event object will not delete the client object in its destructor. | |
183 | The client object must be owned and deleted by another object (e.g. a control) | |
184 | that has longer life time than the event object. | |
185 | ||
f510b7b2 | 186 | \membersection{wxCommandEvent::SetExtraLong}\label{wxcommandeventsetextralong} |
a660d684 | 187 | |
be0ba550 | 188 | \func{void}{SetExtraLong}{\param{long}{ extraLong}} |
a660d684 KB |
189 | |
190 | Sets the {\bf m\_extraLong} member. | |
191 | ||
f510b7b2 | 192 | \membersection{wxCommandEvent::SetInt}\label{wxcommandeventsetint} |
a660d684 KB |
193 | |
194 | \func{void}{SetInt}{\param{int}{ intCommand}} | |
195 | ||
196 | Sets the {\bf m\_commandInt} member. | |
197 | ||
f510b7b2 | 198 | \membersection{wxCommandEvent::SetString}\label{wxcommandeventsetstring} |
a660d684 | 199 | |
ce788ad9 | 200 | \func{void}{SetString}{\param{const wxString\&}{ string}} |
a660d684 KB |
201 | |
202 | Sets the {\bf m\_commandString} member. | |
203 |