uitoolbar

Creates a toolbar with uipushtool or uitoggletool objects in a container object such as a figure, uipanel or uitab.

Syntax

handle = uitoolbar

handle = uitoolbar(property, value, ...)

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

Inputs

parent
Handle of a container object such as a figure, uipanel or uitab.
Type: double | integer
property, value
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.
Type: cell | functionhandle | string
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.
enable
Specifies if handle is enabled. Valid values are on(default) and off.
Type: string
iconsize
Specifies the size of the uipushtool icons.
Type: integer
orient
Specifies the orientation of handle. Valid values are horizontal (default) and vertical.
Type: string
parent
Specifies the parent which must be a figure, uipanel or uitab. If there is no parent specified, the parent will be the default figure, gcf().
Type: scalar
position
Position of handle. Value is specified as a vector of form: [left top]. If 'units' has a value of 'normalized', values must be between 0 to 1.
Type: vector
tag
User-defined string to tag handle.
Type: string
tooltipstring
Tooltip.
Type: string
units
Unit of measurement.
pixels
Default option which indicates that handle has a fixed position specified by position.
normalized
Indicates that handle is moved if parent is moved/resized.
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 uitoolbar created.

Examples

Create a toolbar in the current figure with a vertical orientation:
handle = uitoolbar ('orient', 'vertical'); % Toolbar

pushtool1 = uipushtool(handle, 'iconpath', 'msfolder.png', 'separator', 'on');
pushtool2 = uipushtool('iconpath', 'TableView-16.png'); % Adds to current toolbar
pushtool3 = uipushtool(handle, 'iconpath', 'mslist.png');
pushtool4 = uipushtool(handle, 'iconpath', 'left.png');
Figure 1. Vertical uitoolbar in the current figure


Create a toolbar in a uitab:
% Callback for uipushtool
function pushtool3_callback(handle, data, varargin)
  printf('Executing callback, handle: [%f]\n', handle);
end
    
% Figure
Dialog = figure('units', 'pixels', 'position', [0 0 734 459], 'name','Dialog');

% Tab group
tabWidget = uitabgroup('parent', Dialog, 'units','normalized', 'position',[0.07 0.33 0.75 0.56]);

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

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

set(tabWidget, 'selectedtab', tab);

toolbar = uitoolbar(tab);

pushtool1 = uipushtool(toolbar, 'iconpath', 'msfolder.png', 'separator', 'on');
pushtool2 = uipushtool(toolbar, 'iconpath', 'TableView-16.png'); % Adds to current toolbar
pushtool3 = uipushtool(toolbar, 'iconpath', 'mslist.png', 'clickedcallback','pushtool3_callback');
toggletool1 = uipushtool(toolbar, 'iconpath', 'left.png');
Figure 2. Horizontal toolbar in a tab