User`s guide

Examples: Program GUI C omponents
Check Box
You can determine the current state of a check box from within any of its
callbacks by querying the state of its
Value property, as illustrated in the
following example:
function checkb ox1_ Callback(hObject,eventd ata)
if (get(hObj ect, 'Value') == get(hOb ject,'Max'))
% Checkbox is checked-take appropriate action
else
% Checkbox is not checked-t ake appropriate action
end
hObject
is the handle of the component for which the event was triggered.
You can also change the state of a check box by programmatically by setting
the check box
Value property to the value of the Ma x or Mi n property. For
example,
set(cbh,'Value','Max')
puts the check box with handle cbh in the checked state.
Edit Text
To obtain the string a user types in an edit box, use any of its callbacks to get
the value of the
String property. This e xample uses the Callback callback.
function editte xt1_ Callback(hObject,eventd ata)
user_string = get(hObject,'String');
% Proceed with callback
If the edit text Max and Min properties are set such that Max - Min > 1,the
user can enter m ultiple lines. For example, setting
Max to 2, with the default
value of
0 for Min, enables users to enter multiple lines. If you originally
specify
String as a character string, multiline user input is returned as a 2-D
character array w ith each row containing a line. If you originally specify
String as a cell array, multiline user input is returned as a 2-D cell array of
strings.
hObject is the handle of the component for which the event was triggered.
12-21