Documentation Center

  • Trial Software
  • Product Updates

uitoggletool

Create toggle button on toolbar

Syntax

htt = uitoggletool
htt = uitoggletool('PropertyName1',value1,'PropertyName2',value2,...)
htt = uitoggletool(ht,...)

Description

htt = uitoggletool creates a toggle button on the uitoolbar at the top of the current figure window, sets all its properties to default values, and returns a handle to the tool. If no uitoolbar exists, one is created. The uitoolbar is the parent of the uitoggletool. Use the returned handle htt to set properties of the uitoggletool. The OnCallback, OffCallback and ClickedCallback use the handle as their first argument. The button has no icon, but its border highlights when you hover over it with the mouse cursor. Add an icon by setting CData for the tool. Type get(htt) to see a list of uitoggletool object properties and their current values. Type set(htt) to see a list of uitoggletool object properties you can set and legal property values.

htt = uitoggletool('PropertyName1',value1,'PropertyName2',value2,...) assigns the specified property values, and assigns default values to the remaining properties. You can change the property values at a later time using the set function. You can specify properties as parameter name/value pairs, cell arrays containing parameter names and values, or structures with fields containing parameter names and values as input arguments. For a complete list, see Uitoggletool Properties. Type get(htt) to see a list of uipushtool object properties and their current values. Type set(htt) to see a list of uipushtool object properties that you can set and their legal property values.

htt = uitoggletool(ht,...) creates a button with ht as a parent. ht must be a uitoolbar handle.

Toggle tools appear in figures whose Window Style is normal or docked. They do not appear in figures with a 'modal' WindowStyle. If the WindowStyle property of a figure containing a tool bar and its toggle tool children changes to modal, the toggle tools continue to exist as Children of the tool bar. The toggle tools do not display until you change the WindowStyle to normal or docked.

Examples

Create a uitoolbar object and places a uitoggletool object on it by specifying the toolbar handle as the toggle tool parent. Generate a random set of colors for the tool icon and specify a tool tip.

h = figure('ToolBar','none');
ht = uitoolbar(h);
a = rand(16,16,3);
htt = uitoggletool(ht,'CData',a,'TooltipString','Hello');

Alternatives

You can create toolbars with toggle tools using GUIDE.

See Also

| | | |

Tutorials

Was this topic helpful?