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