User`s guide

Examples: Program GUI C omponents
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 .
Program Toolbar Tools
PushTool”onpage12-37
“Toggle Tool” o n page 12-39
Push Tool
The push tool ClickedCallback property specifies the push tool control
action. The following example creates a push tool and programs it to open a
standard color selection dialog box. You can use the dialog box to set the
background color of the GUI.
1 Copy the following code into a file and save it in your current folder or on
your path as
color_gui.m. Execute the function by typing color_gui
at the command line.
function color_ gui
fh = figure('Position',[250 250 250 150],'Tool bar' ,'none');
th = uitoolbar('Parent',fh);
pth = uipushtool('Parent',th,'C data',rand(20,20,3),...
'ClickedCallback',@color_callback);
%---------------------------------- ---------------------
function color_ call back(hObject,eventdata)
color = uisetcolor(fh,'Pick a color');
end
end
12-37