uipushtool

Creates a tool button in a uitoolbar.

Syntax

handle = uipushtool()

handle = uipushtool(parent)

handle = uipushtool(parent, property, value, ...)

Inputs

parent
Handle of the uitoolbar parent. If there is no parent specified, the parent will be a default uitoolbar in the current figure, gcf.
Type: double | integer
property, value
clickedcallback
Callback function triggered when the handle is clicked.
If value is a function handle, it must be a function that takes at least two arguments: the first is the handle, and the second is the event data to the uipushtool. Compose passes empty data to the second argument if there is no data to the uipushtool.
If value is a string, it must represent a function handle or a function name.
If value is a cell, it must contain the function name/function handle in the first cell element and parameters to pass to the callback function in the additional elements.
clickedcallback can be interrupted using the property interruptible with a value of on
Type: cell | functionhandle | string
createfcn
Function triggered when handle is created.
If value is a function handle, it must be a function that takes at least two arguments: the first is the handle and the second argument is ignored.
If value is a string, it must represent a function handle or a function name.
If value is a cell, it must contain the function name/function handle in the first cell element and parameters to pass to the callback function in the additional elements.
createfcn cannot be interrupted.
Type: cell | functionhandle | string
deletefcn
Function triggered when handle is deleted.
If value is a function handle, it must be a function that takes at least two arguments: the first is the handle and the second argument is ignored.
If value is a string, it must represent a function handle or a function name.
If value is a cell, it must contain the function name/function handle in the first cell element and parameters to pass to the callback function in the additional elements.
deletefcn cannot be interrupted.
Type: cell | functionhandle | string
enable
Specifies if handle is enabled. Valid values are on(default) and off.
Type: string
iconpath
Path to the icon on handle.
Type: string
interruptible
Specifies if clickedcallback can be interrupted by clicking on the Stop button in the user interface. Valid values are off (default) and on.
Type: string
keypressfcn
Function triggered when there a key is pressed on handle.
If value is a function handle, it must be a function that takes at least two arguments: the first is the handle and the second argument is ignored.
If value is a string, it must represent a function handle or a function name.
If value is a cell, it must contain the function name/function handle in the first cell element and parameters to pass to the callback function in the additional elements.
Type: cell | functionhandle | string
parent
Specifies the parent (uitabgroup).
If there is no parent specified, the uipushtool will be created on the current toolbar, uitoolbar on the current figure, gcf.
Type: scalar
separator
Specifies is a separator needs to be added after handle on the parent uitoolbar. Valid values are off (default) and on.
Type: string
tag
User-defined string to tag handle.
Type: string
tooltipstring
Tooltip.
Type: string
userdata
User-defined numerical data.
Type: complex | mtx | scalar
value
User-defined scalar data.
Type: scalar
visible
Specifies if handle is visible. Valid values are on(default) and off.
Type: string

Outputs

handle
Handle of the uipushtool created.

Example

Creates a toolbar with tool buttons in a uipanel:
% Callback function:
function pushtool3_callback(handle, data, varargin)
  printf('Executing callback, handle: [%f]\n', handle);
end

Dialog = figure('units', 'pixels', 'position', [0 0 700 474] ...
           , 'name','Dialog', 'windowstyle','undocked');

uiPanel = uipanel('parent', Dialog, 'units','normalized', 'position',[0.07 0.24 0.89 0.69], 'title','Test');

toolbar = uitoolbar(uiPanel);

% uipushtool with an icon
pushtool1 = uipushtool(toolbar, 'iconpath', 'msfolder.png');

% uipushtool with a separator
pushtool2 = uipushtool(toolbar, 'iconpath', 'TableView-16.png', 'separator', 'on');

% uipushtool with a callback
pushtool3 = uipushtool(toolbar, 'iconpath', 'mslist.png', 'clickedcallback','pushtool3_callback');
Figure 1. Toolbar with toolbuttons in a uipanel