Skip to Main Content Skip to Search
Product Documentation

uipushtool - Create push button on toolbar

Syntax

hpt = uipushtool
hpt = uipushtool('PropertyName1',value1,'PropertyName2',value2,...)
hpt = uipushtool(ht,...)

Description

hpt = uipushtool creates a push button on the uitoolbar at the top of the current figure window, sets all its properties to default values, and returns a handle to the tool. If no uitoolbar exists, one is created. The uitoolbar is the parent of the uipushtool. Use the returned handle hpt to set properties of the tool. The ClickedCallback passes the handle as its first argument. The button has no icon, but its border highlights when you hover over it with the mouse cursor. Add an icon by setting CData for the tool.

hpt = uipushtool('PropertyName1',value1,'PropertyName2',value2,...) , creates a uipushtool and returns a handle to it. uipushtool assigns the specified property values, and assigns default values to the remaining properties. You can change the property values at a later time using the set function. You can specify properties as parameter name/value pairs, cell arrays containing parameter names and values, or structures with fields containing parameter names and values as input arguments. For a complete list, see Uipushtool Properties. Type get(hpt) to see a list of uipushtool object properties and their current values. Type set(hpt) to see a list of uipushtool object properties that you can set and their legal property values.

hpt = uipushtool(ht,...) creates a button with ht as a parent. ht must be a uitoolbar handle.

Uipushtools appear in figures whose Window Style is 'normal' or 'docked'. Push tools do not appear in figures with 'modal' WindowStyle. If you change the WindowStyle of a figure containing a uitoolbar and its uipushtool children to 'modal', the uipushtools continue to exist as Children of the uitoolbar. However, they do not display until you change the figure WindowStyle to 'normal' or 'docked'.

Unlike push buttons, uipushtools have no way to indicate that you have double-clicked them. That is, a double click does not set the figure SelectionType property to 'open'. Double-clicking a uipushtool simply executes its ClickedCallback twice in succession. Also, uipushtools cannot have context menus.

Examples

Create a uitoolbar object and places a uipushtool object on it. Generate an icon for the tool by reading a GIF file containing a MATLAB icon. Convert the indexed image to a truecolor image before specifying it as CData.

h  = figure('ToolBar','none');
ht = uitoolbar(h);
% Use a MATLAB icon for the tool
[X map] = imread(fullfile(...
    matlabroot,'toolbox','matlab','icons','matlabicon.gif'));
% Convert indexed image and colormap to truecolor
icon = ind2rgb(X,map);
% Create a uipushtool in the toolbar
hpt = uipushtool(ht,'CData',icon,...
                 'TooltipString','Toolbar push button',...
                 'ClickedCallback',...
                 'disp(''Thank you for clicking a uipushtool.'')')

Alternatives

You can also create toolbars with push tools using GUIDE.

See Also

get | set | uicontrol | Uipushtool Properties | uitoggletool | uitoolbar

Tutorials

How To

  


» Learn more
» Download free kit
» Get trial software

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS