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.
- property, value
-
- clickedcallback
- Callback function triggered when the handle is clicked.
- createfcn
- Function triggered when handle is created.
- deletefcn
- Function triggered when handle is deleted.
- enable
- Specifies if handle is enabled. Valid values are on(default) and off.
- iconpath
- Path to the icon on handle.
- interruptible
- Specifies if clickedcallback can be interrupted by clicking on the Stop button in the user interface. Valid values are off (default) and on.
- keypressfcn
- Function triggered when there a key is pressed on handle.
- offcallback
- Callback function triggered when the handle is is off.
- oncallback
- Callback function triggered when the handle is is on.
- parent
- Specifies the parent (uitabgroup).
- separator
- Specifies is a separator needs to be added after handle on the parent uitoolbar. Valid values are off (default) and on.
- tag
- User-defined string to tag handle.
- tooltipstring
- Tooltip.
- userdata
- User-defined numerical data.
- value
- User-defined scalar data.
- visible
- Specifies if handle is visible. Valid values are on(default) and off.
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');