Create push button on toolbar
p = uipushtool
p = uipushtool(Name,Value,...)
p = uipushtool(parent)
p = uipushtool(parent,Name,Value,...)
p = uipushtool
creates a uipushtool in
the current figure's uitoolbar and returns the uipushtool object, p
.
If there is no uitoolbar available, then MATLAB® creates a new
uitoolbar in the current figure to serve as the parent. Similarly,
if there no figure is available, then MATLAB creates a new figure
with a uitoolbar.
p = uipushtool(Name,Value,...)
creates
a uipushtool and specifies one or more uipushtool property names and
corresponding values. Use this syntax to override the default uipushtool
properties.
p = uipushtool(parent)
creates a uipushtool and designates a specific parent object. The parent
argument
must be a uitoolbar object.
p = uipushtool(parent,Name,Value,...)
creates a uipushtool with a specific parent and one or more uipushtool
properties.
A uipushtool is a push button that appears in the figure's
tool bar. The button has no icon, but its borders highlight when the
user hovers over it with the mouse. You can create a button icon by
setting the uipushtool's CData
property.
f = figure('ToolBar','none'); t = uitoolbar(f); % Read an image [img,map] = imread(fullfile(matlabroot,... 'toolbox','matlab','icons','matlabicon.gif')); % Convert image from indexed to truecolor icon = ind2rgb(img,map); % Create a uipushtool in the toolbar p = uipushtool(t,'TooltipString','Toolbar push button',... 'ClickedCallback',... 'disp(''Clicked uipushtool.'')'); % Set the button icon p.CData = icon;