uitoggletool

Creates a toggle tool button in a uitoolbar.

Syntax

handle = uitoggletool()

handle = uitoggletool(parent)

handle = uitoggletool(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 uitoggletool. Compose passes empty data to the second argument if there is no data to the uitoggletool.
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
offcallback
Callback function triggered when the handle is is off.
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 uitoggletool.
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.
offcallback can be interrupted using the property interruptible with a value of on
Type: cell | functionhandle | string
oncallback
Callback function triggered when the handle is is on.
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 uitoggletool.
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.
oncallback can be interrupted using the property interruptible with a value of on.
Type: cell | functionhandle | string
parent
Specifies the parent (uitabgroup).
If there is no parent specified, the uitoggletool 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 uitoggletool created.

Example

Creates a toolbar with tool buttons in a uitab:
% Callback functions:
function button_callback(handle, data, varargin)
  printf('Executing [%s] callback, handle: [%f]\n', get(handle, 'type'), handle);
end

function toggleonfunc(handle, data, varargin)
  printf('Toggle button handle [%f] state: on\n', handle);
end

function toggleofffunc(handle, data, varargin)
  printf('Toggle button handle [%f] state: off\n', handle);
end

% GUI objects:
Dialog = figure('units', 'pixels', 'position', [0 0 734 459] ...
                , 'name','Dialog', 'windowstyle','undocked');

tabWidget = uitabgroup('parent', Dialog);

tab = uitab('parent', tabWidget, 'title','Tab 1');

tab_2 = uitab('parent', tabWidget, 'title','Tab 2');

toolbar = uitoolbar(tab);

pushtool1 = uipushtool(toolbar, 'iconpath', 'msfolder.png', 'separator', 'on');

pushtool2 = uipushtool(toolbar, 'iconpath', 'TableView-16.png', 'clickedcallback','button_callback', 'value', 10);

toggle3 = uitoggletool(toolbar, 'iconpath', 'mslist.png', 'value', 1, 'clickedcallback','button_callback');

toggle4 = uitoggletool(toolbar, 'iconpath', 'left.png' ...
                       , 'oncallback', 'toggleonfunc', 'offcallback', 'toggleofffunc');
Figure 1. Toolbar with tool buttons in a uitab