uipushtool
Create push button on toolbar
Syntax
p = uipushtool
p = uipushtool(Name,Value,...)
p = uipushtool(parent)
p = uipushtool(parent,Name,Value,...)
Description
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父
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’sCData
property.
Examples
Create uipushtool With Icon and Tool Tip
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 truecoloricon = ind2rgb(img,map);% Create a uipushtool in the toolbarp = uipushtool(t,'TooltipString','Toolbar push button',...'ClickedCallback',...'disp(''Clicked uipushtool.'')');% Set the button iconp.CData = icon;
Tips
Uitoolbars (and their child uipushtools) do not appear in figures whose
WindowStyle
property is set to'Modal'
. If a figure containing a uitoolbar is changed to'Modal'
, the uitoolbar still exists in theChildren
property of the figure. However, the uitoolbar does not display whileWindowStyle
is set to'Modal'
.Unlike uicontrol push buttons, uipushtools do not set the figure’s
SelectionType
property to'open'
on the second click.