uitogglebutton
R2026bCreate toggle button component
Description
creates a toggle button in a
new figure and returns the tb = uitogglebuttonToggleButton object. MATLAB® calls the uifigure function to create the figure.
specifies tb = uitogglebutton(___,Name=Value)ToggleButton properties using one or more name-value arguments. Use
this option with any of the input argument combinations in the previous syntaxes.
Examples
Input Arguments
Name-Value Arguments
Tips
To manage exclusive selection of radio buttons or toggle buttons, use the
uiselectiongroupfunction to create a selection group. Buttons managed by a selection group can be in any container within the same figure.To make your program respond when a user selects a toggle button managed by a selection group, define a
SelectionChangedFcncallback for theSingleSelectionGroupobject. You cannot define callbacks for the individual buttons.To determine which toggle button is currently selected, query the
SelectedObjectproperty of theSingleSelectionGroupobject. For example,sg.SelectedObjectreturns the currently selected button in the selection groupsg. You can execute this query anywhere in your code.If you use a
ButtonGroupobject as the parent container for toggle buttons that are managed by a selection group, then only the selection group manages the selection of the buttons. (since R2026b)

