Create push button on toolbar

Use this function only with GUIDE, or with figures created using the figure function.


p = uipushtool
p = uipushtool(Name,Value,...)
p = uipushtool(parent)
p = uipushtool(parent,Name,Value,...)


p = uipushtool creates a uipushtool in the uitoolbar of the current figure 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 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 CData property of the uipushtool.


Create uipushtool With Icon and Tool Tip

f  = figure('ToolBar','none');
t = uitoolbar(f);

% Read an image
[img,map] = imread(fullfile(matlabroot,...

% Convert image from indexed to truecolor
icon = ind2rgb(img,map);

% Create a uipushtool in the toolbar
p = uipushtool(t,'TooltipString','Toolbar push button',...
                 'disp(''Clicked uipushtool.'')');

% Set the button icon
p.CData = icon;


  • 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 the Children property of the figure. However, the uitoolbar does not display while WindowStyle is set to 'Modal'.

  • Unlike uicontrol push buttons, uipushtools do not set the figure’s SelectionType property to 'open' on the second click.

Introduced before R2006a