
GUI with Axes, Menu, and Toolbar
12-15
• The uicontrol function creates various user interface controls based on the
value of the
Style property. This statement does not set the Style property
because its default is
pushbutton.
• For a push button, the
String property defines the label on the button. Here
it is defined as the string
Update.
• Setting the
Callback property to @hUpdateButtonCallback defines the name
of the callback function that services the push button. That is, clicking the
push button triggers the execution of the named callback. This callback
function is defined later in the script.
See the Uicontrol Properties reference page for information about properties of
uicontrol objects and their default values.
The File Menu and Its Menu Items
These statements define the File menu and the three items it contains.
hFileMenu = uimenu(... % File menu
'Parent',hMainFigure,...
'HandleVisibility','callback', ...
'Label','File');
hOpenMenuitem = uimenu(... % Open menu item
'Parent',hFileMenu,...
'Label','Open',...
'HandleVisibility','callback', ...
'Callback', @hOpenMenuitemCallback);
hPrintMenuitem = uimenu(... % Print menu item
'Parent',hFileMenu,...
'Label','Print',...
'HandleVisibility','callback', ...
'Callback', @hPrintMenuitemCallback);
hCloseMenuitem = uimenu(... % Close menu item
'Parent',hFileMenu,...
'Label','Close',...
'Separator','on',...
'HandleVisibility','callback', ...
'Callback', @hCloseMenuitemCallback');
• The uimenu function creates both the main menu, File, and the items it
contains. For the main menu and each of its items, set the
Parent property
to the handle of the desired parent to create the menu hierarchy you want.
Commentaires sur ces manuels