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.
- property, value
-
- 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.
- iconsize
- Specifies the size of the uipushtool icons.
- orient
- Specifies the orientation of handle. Valid values are horizontal (default) and vertical.
- 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().
- 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.
- tag
- User-defined string to tag handle.
- tooltipstring
- Tooltip.
- units
- Unit of measurement.
- 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 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');
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');