1 \section{\class{wxCommandEvent
}}\label{wxcommandevent
}
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.
6 \wxheading{Derived from
}
8 \helpref{wxEvent
}{wxevent
}
10 \wxheading{Include files
}
14 \wxheading{Event table macros
}
16 To process a menu command event, use these event handler macros to direct input to member
17 functions that take a wxCommandEvent argument.
20 \begin{twocollist
}\itemsep=
0pt
21 \twocolitem{{\bf EVT
\_COMMAND(id, event, func)
}}{Process a command, supplying the window identifier,
22 command event identifier, and member function.
}
23 \twocolitem{{\bf EVT
\_COMMAND\_RANGE(id1, id2, event, func)
}}{Process a command for a range
24 of window identifiers, supplying the minimum and maximum window identifiers,
25 command event identifier, and member function.
}
26 \twocolitem{{\bf EVT
\_BUTTON(id, func)
}}{Process a wxEVT
\_COMMAND\_BUTTON\_CLICKED command,
27 which is generated by a wxButton control.
}
28 \twocolitem{{\bf EVT
\_CHECKBOX(id, func)
}}{Process a wxEVT
\_COMMAND\_CHECKBOX\_CLICKED command,
29 which is generated by a wxCheckBox control.
}
30 \twocolitem{{\bf EVT
\_CHOICE(id, func)
}}{Process a wxEVT
\_COMMAND\_CHOICE\_SELECTED command,
31 which is generated by a wxChoice control.
}
32 \twocolitem{{\bf EVT
\_COMBOBOX(id, func)
}}{Process a wxEVT
\_COMMAND\_COMBOBOX\_SELECTED command,
33 which is generated by a wxComboBox control.
}
34 \twocolitem{{\bf EVT
\_LISTBOX(id, func)
}}{Process a wxEVT
\_COMMAND\_LISTBOX\_SELECTED command,
35 which is generated by a wxListBox control.
}
36 \twocolitem{{\bf EVT
\_LISTBOX\_DCLICK(id, func)
}}{Process a wxEVT
\_COMMAND\_LISTBOX\_DOUBLECLICKED command,
37 which is generated by a wxListBox control.
}
38 \twocolitem{{\bf EVT
\_MENU(id, func)
}}{Process a wxEVT
\_COMMAND\_MENU\_SELECTED command,
39 which is generated by a menu item.
}
40 \twocolitem{{\bf EVT
\_MENU\_RANGE(id1, id2, func)
}}{Process a wxEVT
\_COMMAND\_MENU\_RANGE command,
41 which is generated by a range of menu items.
}
42 \twocolitem{{\bf EVT
\_CONTEXT\_MENU(func)
}}{Process the event generated
43 when the user has requested a popup menu to appear by pressing a special
44 keyboard key (under Windows) or by right clicking the mouse.
}
45 \twocolitem{{\bf EVT
\_RADIOBOX(id, func)
}}{Process a wxEVT
\_COMMAND\_RADIOBOX\_SELECTED command,
46 which is generated by a wxRadioBox control.
}
47 \twocolitem{{\bf EVT
\_RADIOBUTTON(id, func)
}}{Process a wxEVT
\_COMMAND\_RADIOBUTTON\_SELECTED command,
48 which is generated by a wxRadioButton control.
}
49 \twocolitem{{\bf EVT
\_SCROLLBAR(id, func)
}}{Process a wxEVT
\_COMMAND\_SCROLLBAR\_UPDATED command,
50 which is generated by a wxScrollBar control. This is provided for compatibility only;
51 more specific scrollbar event macros should be used instead (see
\helpref{wxScrollEvent
}{wxscrollevent
}).
}
52 \twocolitem{{\bf EVT
\_SLIDER(id, func)
}}{Process a wxEVT
\_COMMAND\_SLIDER\_UPDATED command,
53 which is generated by a wxSlider control.
}
54 \twocolitem{{\bf EVT
\_TEXT(id, func)
}}{Process a wxEVT
\_COMMAND\_TEXT\_UPDATED command,
55 which is generated by a wxTextCtrl control.
}
56 \twocolitem{{\bf EVT
\_TEXT\_ENTER(id, func)
}}{Process a wxEVT
\_COMMAND\_TEXT\_ENTER command,
57 which is generated by a wxTextCtrl control. Note that you must use
58 wxTE
\_PROCESS\_ENTER flag when creating the control if you want it to generate
60 \twocolitem{{\bf EVT
\_TEXT\_MAXLEN(id, func)
}}{Process a wxEVT
\_COMMAND\_TEXT\_MAXLEN command,
61 which is generated by a wxTextCtrl control when the user tries to enter more
62 characters into it than the limit previously set with
63 \helpref{SetMaxLength
}{wxtextctrlsetmaxlength
}.
}
64 \twocolitem{{\bf EVT
\_TOOL(id, func)
}}{Process a wxEVT
\_COMMAND\_TOOL\_CLICKED event
65 (a synonym for wxEVT
\_COMMAND\_MENU\_SELECTED). Pass the id of the tool.
}
66 \twocolitem{{\bf EVT
\_TOOL\_RANGE(id1, id2, func)
}}{Process a wxEVT
\_COMMAND\_TOOL\_CLICKED event
67 for a range of identifiers. Pass the ids of the tools.
}
68 \twocolitem{{\bf EVT
\_TOOL\_RCLICKED(id, func)
}}{Process a wxEVT
\_COMMAND\_TOOL\_RCLICKED event.
69 Pass the id of the tool.
}
70 \twocolitem{{\bf EVT
\_TOOL\_RCLICKED\_RANGE(id1, id2, func)
}}{Process a wxEVT
\_COMMAND\_TOOL\_RCLICKED event
71 for a range of ids. Pass the ids of the tools.
}
72 \twocolitem{{\bf EVT
\_TOOL\_ENTER(id, func)
}}{Process a wxEVT
\_COMMAND\_TOOL\_ENTER event.
73 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.
}
74 \twocolitem{{\bf EVT
\_COMMAND\_LEFT\_CLICK(id, func)
}}{Process a wxEVT
\_COMMAND\_LEFT\_CLICK command,
75 which is generated by a control (Windows
95 and NT only).
}
76 \twocolitem{{\bf EVT
\_COMMAND\_LEFT\_DCLICK(id, func)
}}{Process a wxEVT
\_COMMAND\_LEFT\_DCLICK command,
77 which is generated by a control (Windows
95 and NT only).
}
78 \twocolitem{{\bf EVT
\_COMMAND\_RIGHT\_CLICK(id, func)
}}{Process a wxEVT
\_COMMAND\_RIGHT\_CLICK command,
79 which is generated by a control (Windows
95 and NT only).
}
80 \twocolitem{{\bf EVT
\_COMMAND\_SET\_FOCUS(id, func)
}}{Process a wxEVT
\_COMMAND\_SET\_FOCUS command,
81 which is generated by a control (Windows
95 and NT only).
}
82 \twocolitem{{\bf EVT
\_COMMAND\_KILL\_FOCUS(id, func)
}}{Process a wxEVT
\_COMMAND\_KILL\_FOCUS command,
83 which is generated by a control (Windows
95 and NT only).
}
84 \twocolitem{{\bf EVT
\_COMMAND\_ENTER(id, func)
}}{Process a wxEVT
\_COMMAND\_ENTER command,
85 which is generated by a control.
}
88 \latexignore{\rtfignore{\wxheading{Members
}}}
90 \membersection{wxCommandEvent::wxCommandEvent
}\label{wxcommandeventctor
}
92 \func{}{wxCommandEvent
}{\param{WXTYPE
}{ commandEventType =
0},
\param{int
}{ id =
0}}
96 \membersection{wxCommandEvent::Checked
}\label{wxcommandeventchecked
}
98 \constfunc{bool
}{Checked
}{\void}
100 Deprecated, use
\helpref{IsChecked
}{wxcommandeventischecked
} instead.
102 \membersection{wxCommandEvent::GetClientData
}\label{wxcommandeventgetclientdata
}
104 \func{void*
}{GetClientData
}{\void}
106 Returns client data pointer for a listbox or choice selection event
107 (not valid for a deselection).
109 \membersection{wxCommandEvent::GetClientObject
}\label{wxcommandeventgetclientobject
}
111 \func{wxClientData *
}{GetClientObject
}{\void}
113 Returns client object pointer for a listbox or choice selection event
114 (not valid for a deselection).
116 \membersection{wxCommandEvent::GetExtraLong
}\label{wxcommandeventgetextralong
}
118 \func{long
}{GetExtraLong
}{\void}
120 Returns extra information dependant on the event objects type.
121 If the event comes from a listbox selection, it is a boolean
122 determining whether the event was a selection (true) or a
123 deselection (false). A listbox deselection only occurs for
124 multiple-selection boxes, and in this case the index and string values
125 are indeterminate and the listbox must be examined by the application.
127 \membersection{wxCommandEvent::GetInt
}\label{wxcommandeventgetint
}
129 \func{int
}{GetInt
}{\void}
131 Returns the integer identifier corresponding to a listbox, choice or
132 radiobox selection (only if the event was a selection, not a
133 deselection), or a boolean value representing the value of a checkbox.
135 \membersection{wxCommandEvent::GetSelection
}\label{wxcommandeventgetselection
}
137 \func{int
}{GetSelection
}{\void}
139 Returns item index for a listbox or choice selection event (not valid for
142 \membersection{wxCommandEvent::GetString
}\label{wxcommandeventgetstring
}
144 \func{wxString
}{GetString
}{\void}
146 Returns item string for a listbox or choice selection event (not valid for
149 \membersection{wxCommandEvent::IsChecked
}\label{wxcommandeventischecked
}
151 \constfunc{bool
}{IsChecked
}{\void}
153 This method can be used with checkbox and menu events: for the checkboxes, the
154 method returns
{\tt true
} for a selection event and
{\tt false
} for a
155 deselection one. For the menu events, this method indicates if the menu item
156 just has become checked or unchecked (and thus only makes sense for checkable
159 \membersection{wxCommandEvent::IsSelection
}\label{wxcommandeventisselection
}
161 \func{bool
}{IsSelection
}{\void}
163 For a listbox or similar event, returns true if it is a selection, false if it
166 \membersection{wxCommandEvent::SetClientData
}\label{wxcommandeventsetclientdata
}
168 \func{void
}{SetClientData
}{\param{void*
}{ clientData
}}
170 Sets the client data for this event.
172 \membersection{wxCommandEvent::SetClientObject
}\label{wxcommandeventsetclientobject
}
174 \func{void
}{SetClientObject
}{\param{wxClientData*
}{ clientObject
}}
176 Sets the client object for this event. The client object is
\emph{not
} owned by the event
177 object and the event object will not delete the client object in its destructor.
178 The client object must be owned and deleted by another object (e.g. a control)
179 that has longer life time than the event object.
181 \membersection{wxCommandEvent::SetExtraLong
}\label{wxcommandeventsetextralong
}
183 \func{void
}{SetExtraLong
}{\param{int
}{ extraLong
}}
185 Sets the
{\bf m
\_extraLong} member.
187 \membersection{wxCommandEvent::SetInt
}\label{wxcommandeventsetint
}
189 \func{void
}{SetInt
}{\param{int
}{ intCommand
}}
191 Sets the
{\bf m
\_commandInt} member.
193 \membersection{wxCommandEvent::SetString
}\label{wxcommandeventsetstring
}
195 \func{void
}{SetString
}{\param{const wxString\&
}{ string
}}
197 Sets the
{\bf m
\_commandString} member.