User`s guide

Add Code for Components in C allbacks
Updating a Menu Item Check
A check is useful to indicate the current state of some menu items. If you
selected Check mark this item in the Menu Editor, the item initially
appears checked. Each time the user selects the menu item, the callback for
that item must turn the check on or off. The following example show s you how
to do this by changing the value of the menu item’s
Checked property.
if strcmp(get(h Obje ct, 'Checked'),'on')
set(hObject,'Checked','off');
else
set(hObject,'Checked','on');
end
hObject
is the handle of the component, for which the callback was triggered.
The
strcmp function compares two strings and returns logical 1 (true)ifthe
two are identical and logical
0 (false) otherwise.
Use of checks when the GUI is first displayed should be consistent with the
display. For example, if your GUI has an axes that is visible when a user first
opens it and the GUI has a Show axes menuitem,besuretosetthemenu
item’s
Checked property on w h en you create it so that a check appears next to
the Show axes menu item initia lly .
Note From the Menu Editor, you can view a menu item’s C allback callback
in your editor by selecting the menu item and clicking the View button.
8-61