diff --git a/deploy/Toolbox Packaging Project.prj b/deploy/Toolbox Packaging Project.prj index 005e96a..d7082e9 100644 --- a/deploy/Toolbox Packaging Project.prj +++ b/deploy/Toolbox Packaging Project.prj @@ -29,7 +29,7 @@ https://www.mathworks.com/matlabcentral/fileexchange/66235-widgets-toolbox Planning a complex or business-critical app? MathWorks Consulting can advise you on design and architecture: https://www.mathworks.com/services/consulting/proven-solutions/software-development-with-matlab.html ${PROJECT_ROOT}\widgets_logo.png - 2.2.0 + 2.2.1 ${PROJECT_ROOT}\Widgets Toolbox - MATLAB App Designer Components.mltbx MATLAB diff --git a/widgets/+wt/FileSelector.m b/widgets/+wt/FileSelector.m index 5b8ede6..b7c3899 100644 --- a/widgets/+wt/FileSelector.m +++ b/widgets/+wt/FileSelector.m @@ -355,8 +355,9 @@ function setValueFromFullPath(obj,fullPath) numAbove = max(numel(rootParts) - idx + 1, 0); if numAbove>0 - obj.throwError("Path '%s' is not within the root directory '%s'.",... - fullPath, obj.RootDirectory); + msg = "Select a path beneath the root:" + ... + newline + newline + obj.RootDirectory; + obj.throwError(msg); else diff --git a/widgets/examples/html/WidgetExamples.html b/widgets/examples/html/WidgetExamples.html index bc25ae4..7531f55 100644 --- a/widgets/examples/html/WidgetExamples.html +++ b/widgets/examples/html/WidgetExamples.html @@ -34,7 +34,7 @@ .S9 { border-left: 1px solid rgb(191, 191, 191); border-right: 1px solid rgb(191, 191, 191); border-top: 1px solid rgb(191, 191, 191); border-bottom: 1px solid rgb(191, 191, 191); border-radius: 4px 4px 0px 0px; padding: 6px 45px 4px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: rgb(33, 33, 33); font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px; } .S10 { border-left: 1px solid rgb(191, 191, 191); border-right: 1px solid rgb(191, 191, 191); border-top: 0px none rgb(33, 33, 33); border-bottom: 1px solid rgb(191, 191, 191); border-radius: 0px 0px 4px 4px; padding: 0px 45px 4px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: rgb(33, 33, 33); font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px; } .S11 { margin: 10px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; } -.S12 { margin: 15px 10px 5px 4px; padding: 0px; line-height: 18px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 17px; font-weight: 700; text-align: left; }

Widgets Toolbox - MATLAB App Designer Components - Examples

Widgets Toolbox helps you efficiently develop advanced user interfaces in MATLAB and App Designer. Widgets combine existing control functionalities together into larger, reusable, common functionality to accelerate development of graphical user interfaces.
Copyright 2020-2022 The MathWorks, Inc.

Button Grid

% Create a figure with a grid layout
figObj = uifigure("Position",[100 100 250 75]);
gridObj = uigridlayout(figObj,[1 1],"BackgroundColor",[.6 .8 1]);
 
% Create the widget
buttonGridWidget = wt.ButtonGrid(gridObj);
 
% Configure the widget
buttonGridWidget.BackgroundColor = [.6 .8 1];
 
% Add optional icons
buttonGridWidget.Icon = [
"add_24.png"
"delete_24.png"
"play_24.png"
"pause_24.png"
"stop_24.png"
];
 
% Add optional text
buttonGridWidget.Text = [
"Add"
"Delete"
"Play"
"Pause"
"Stop"
];
 
% Add optional tooltip
buttonGridWidget.Tooltip = [
"Press to Add"
"Press to Delete"
"Press to Play"
"Press to Pause"
"Press to Stop"
];
 
% Assign a callback
buttonGridWidget.ButtonPushedFcn = @(src,evt)disp(evt)
buttonGridWidget =
ButtonGrid with properties: +.S12 { margin: 15px 10px 5px 4px; padding: 0px; line-height: 18px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 17px; font-weight: 700; text-align: left; }

Widgets Toolbox - MATLAB App Designer Components - Examples

Widgets Toolbox helps you efficiently develop advanced user interfaces in MATLAB and App Designer. Widgets combine existing control functionalities together into larger, reusable, common functionality to accelerate development of graphical user interfaces.
Copyright 2020-2022 The MathWorks, Inc.

Button Grid

% Create a figure with a grid layout
figObj = uifigure("Position",[100 100 250 75]);
gridObj = uigridlayout(figObj,[1 1],"BackgroundColor",[.6 .8 1]);
 
% Create the widget
buttonGridWidget = wt.ButtonGrid(gridObj);
 
% Configure the widget
buttonGridWidget.BackgroundColor = [.6 .8 1];
 
% Add optional icons
buttonGridWidget.Icon = [
"add_24.png"
"delete_24.png"
"play_24.png"
"pause_24.png"
"stop_24.png"
];
 
% Add optional text
buttonGridWidget.Text = [
"Add"
"Delete"
"Play"
"Pause"
"Stop"
];
 
% Add optional tooltip
buttonGridWidget.Tooltip = [
"Press to Add"
"Press to Delete"
"Press to Play"
"Press to Pause"
"Press to Stop"
];
 
% Assign a callback
buttonGridWidget.ButtonPushedFcn = @(src,evt)disp(evt)
buttonGridWidget =
ButtonGrid with properties: Icon: ["add_24.png" "delete_24.png" "play_24.png" "pause_24.png" "stop_24.png"] Text: ["Add" "Delete" "Play" "Pause" "Stop"] @@ -50,7 +50,7 @@ Position: [11 11 230 55] Show all properties -

Checkbox List

% Create a figure with a grid layout
figObj = uifigure("Position",[100 100 250 200]);
gridObj = uigridlayout(figObj,[1 1],"BackgroundColor",[.6 .8 1]);
 
% Create the widget
cbListWidget = wt.CheckboxList(gridObj);
 
% Configure the widget
cbListWidget.Items = [
"Boston"
"Chicago"
"Houston"
"Los Angeles"
"Miami"
"New York"
"Seattle"
];
cbListWidget.Value(3) = false;
 
% This is optional (default is false)
cbListWidget.ShowSelectAll = true;
 
% Assign a callback
cbListWidget.ValueChangedFcn = @(src,evt)disp(evt)
cbListWidget =
CheckboxList with properties: +

Checkbox List

% Create a figure with a grid layout
figObj = uifigure("Position",[100 100 250 200]);
gridObj = uigridlayout(figObj,[1 1],"BackgroundColor",[.6 .8 1]);
 
% Create the widget
cbListWidget = wt.CheckboxList(gridObj);
 
% Configure the widget
cbListWidget.Items = [
"Boston"
"Chicago"
"Houston"
"Los Angeles"
"Miami"
"New York"
"Seattle"
];
cbListWidget.Value(3) = false;
 
% This is optional (default is false)
cbListWidget.ShowSelectAll = true;
 
% Assign a callback
cbListWidget.ValueChangedFcn = @(src,evt)disp(evt)
cbListWidget =
CheckboxList with properties: Items: [7×1 string] Value: [7×1 logical] @@ -59,7 +59,7 @@ Position: [11 11 230 180] Show all properties -

Color Selector

% Create a figure with a grid layout
figObj = uifigure("Position",[100 100 250 45]);
gridObj = uigridlayout(figObj,[1 1],"BackgroundColor",[.6 .8 1]);
 
% Create the widget
colorWidget = wt.ColorSelector(gridObj);
 
% Configure the widget
colorWidget.Value = [1 0 0];
 
% Assign a callback
colorWidget.ValueChangedFcn = @(src,evt)disp(evt)
colorWidget =
ColorSelector with properties: +

Color Selector

% Create a figure with a grid layout
figObj = uifigure("Position",[100 100 250 45]);
gridObj = uigridlayout(figObj,[1 1],"BackgroundColor",[.6 .8 1]);
 
% Create the widget
colorWidget = wt.ColorSelector(gridObj);
 
% Configure the widget
colorWidget.Value = [1 0 0];
 
% Assign a callback
colorWidget.ValueChangedFcn = @(src,evt)disp(evt)
colorWidget =
ColorSelector with properties: Value: [1 0 0] ShowEditField: on @@ -67,13 +67,13 @@ Position: [100 100 100 100] Show all properties -
 
If you want to have only the button with no edit field:
% Change the color
colorWidget.Value = [0 1 0];
 
% Turn off the edit field
colorWidget.ShowEditField = false;
 
% Make it a sensible width
gridObj.ColumnWidth = {27}
gridObj =
GridLayout with properties: +
 
If you want to have only the button with no edit field:
% Change the color
colorWidget.Value = [0 1 0];
 
% Turn off the edit field
colorWidget.ShowEditField = false;
 
% Make it a sensible width
gridObj.ColumnWidth = {27}
gridObj =
GridLayout with properties: RowHeight: {'1x'} ColumnWidth: {[27]} Show all properties -

Datetime Selector

% Create a figure with a grid layout
figObj = uifigure("Position",[100 100 350 45]);
gridObj = uigridlayout(figObj,[1 1],"BackgroundColor",[.6 .8 1]);
 
% Create the widget
dateWidget = wt.DatetimeSelector(gridObj)
dateWidget =
DatetimeSelector with properties: +

Datetime Selector

% Create a figure with a grid layout
figObj = uifigure("Position",[100 100 350 45]);
gridObj = uigridlayout(figObj,[1 1],"BackgroundColor",[.6 .8 1]);
 
% Create the widget
dateWidget = wt.DatetimeSelector(gridObj)
dateWidget =
DatetimeSelector with properties: Value: 08-Apr-2022 12:00 AM ShowAMPM: on @@ -86,7 +86,7 @@ Position: [100 100 100 100] Show all properties -
If you want to configure the widget differently:
% Configure the widget
dateWidget.DateFormat = "MM/dd/uuuu";
dateWidget.DisabledDaysOfWeek = ["Saturday" "Sunday"];
dateWidget.Value = datetime("now","TimeZone","local");
dateWidget.ShowSeconds = "on";
dateWidget.ShowAMPM = "off";

File Selector

% Create a figure with a grid layout
figObj = uifigure("Position",[100 100 250 45]);
gridObj = uigridlayout(figObj,[1 1],"BackgroundColor",[.6 .8 1]);
 
% Create the widget
fileWidget = wt.FileSelector(gridObj);
 
% Configure the widget
fileWidget.Value = matlabroot;
 
% Assign a callback
fileWidget.ValueChangedFcn = @(src,evt)disp(evt)
fileWidget =
FileSelector with properties: +
If you want to configure the widget differently:
% Configure the widget
dateWidget.DateFormat = "MM/dd/uuuu";
dateWidget.DisabledDaysOfWeek = ["Saturday" "Sunday"];
dateWidget.Value = datetime("now","TimeZone","local");
dateWidget.ShowSeconds = "on";
dateWidget.ShowAMPM = "off";

File Selector

% Create a figure with a grid layout
figObj = uifigure("Position",[100 100 250 45]);
gridObj = uigridlayout(figObj,[1 1],"BackgroundColor",[.6 .8 1]);
 
% Create the widget
fileWidget = wt.FileSelector(gridObj);
 
% Configure the widget
fileWidget.Value = matlabroot;
 
% Assign a callback
fileWidget.ValueChangedFcn = @(src,evt)disp(evt)
fileWidget =
FileSelector with properties: Value: "C:\Program Files\MATLAB\R2022a" FullPath: "C:\Program Files\MATLAB\R2022a" @@ -100,7 +100,7 @@ Position: [100 100 100 100] Show all properties -
If you want to have a dropdown button to show recent history:
fileWidget.ShowHistory = true;

List Selector (single pane)

The List Selector widget is intended for adding items to a list from a known set. You can optionally enable reordering the items, and add custom buttons.
% Create a figure with a grid layout
figObj = uifigure("Position",[100 100 250 215]);
gridObj = uigridlayout(figObj,[1 1],"BackgroundColor",[.6 .8 1]);
 
% Create the widget
listWidget = wt.ListSelector(gridObj);
listWidget.Items = ["California","Massachusetts","Michigan","Texas"];
listWidget.Value = ["Massachusetts","Michigan"];
 
% Assign a callback
listWidget.ValueChangedFcn = @(src,evt)disp(evt)
listWidget =
ListSelector with properties: +
If you want to have a dropdown button to show recent history:
fileWidget.ShowHistory = true;

List Selector (single pane)

The List Selector widget is intended for adding items to a list from a known set. You can optionally enable reordering the items, and add custom buttons.
% Create a figure with a grid layout
figObj = uifigure("Position",[100 100 250 215]);
gridObj = uigridlayout(figObj,[1 1],"BackgroundColor",[.6 .8 1]);
 
% Create the widget
listWidget = wt.ListSelector(gridObj);
listWidget.Items = ["California","Massachusetts","Michigan","Texas"];
listWidget.Value = ["Massachusetts","Michigan"];
 
% Assign a callback
listWidget.ValueChangedFcn = @(src,evt)disp(evt)
listWidget =
ListSelector with properties: Items: ["California" "Massachusetts" "Michigan" "Texas"] ItemsData: [1×0 double] @@ -117,7 +117,7 @@ Position: [100 100 100 100] Show all properties -
You can also add your own custom buttons:
listWidget.UserButtons.Icon = ["plot_24.png","play_24.png"];
listWidget.UserButtons.ButtonHeight = {25 25};
listWidget.ButtonPushedFcn = @(src,evt)disp(evt);

List Selector Two Pane

The List Selector Two-Pane widget is similar to the one-pane variant. It is intended for adding items to a list from a known set. In this case, the set of available items is displayed in a list on the left side, and items are selectively added to the right list.
Again you can optionally enable reordering the items and add custom buttons.
% Create a figure with a grid layout
figObj = uifigure("Position",[100 100 300 215]);
gridObj = uigridlayout(figObj,[1 1],"BackgroundColor",[.6 .8 1]);
 
% Create the widget
listWidget2 = wt.ListSelectorTwoPane(gridObj);
listWidget2.Items = ["California","Massachusetts","Michigan","Texas"];
listWidget2.Value = ["Massachusetts","Michigan"];

Password Field

% Create a figure with a grid layout
figObj = uifigure("Position",[100 100 250 45]);
gridObj = uigridlayout(figObj,[1 2],"BackgroundColor",[.6 .8 1]);
gridObj.ColumnWidth = {'fit','1x'};
 
% Add label
uilabel(gridObj,"Text","Password:");
This component won't show in the preview, but it will create a password field with text displayed as dots.
% Create the widget
passwordWidget = wt.PasswordField(gridObj);
 
% Configure the widget
passwordWidget.Value = "MathWorks";

Progress Bar

% Create a figure with a grid layout
figObj = uifigure("Position",[100 100 300 60]);
gridObj = uigridlayout(figObj,[1 1],"BackgroundColor",[.6 .8 1]);
 
% Create the widget
progressWidget = wt.ProgressBar(gridObj);
 
% Configure the widget
progressWidget.ShowCancel = true;
 
% Assign a callback
progressWidget.CancelPressedFcn = @(h,e)disp("Cancel Pressed!")
progressWidget =
ProgressBar with properties: +
You can also add your own custom buttons:
listWidget.UserButtons.Icon = ["plot_24.png","play_24.png"];
listWidget.UserButtons.ButtonHeight = {25 25};
listWidget.ButtonPushedFcn = @(src,evt)disp(evt);

List Selector Two Pane

The List Selector Two-Pane widget is similar to the one-pane variant. It is intended for adding items to a list from a known set. In this case, the set of available items is displayed in a list on the left side, and items are selectively added to the right list.
Again you can optionally enable reordering the items and add custom buttons.
% Create a figure with a grid layout
figObj = uifigure("Position",[100 100 300 215]);
gridObj = uigridlayout(figObj,[1 1],"BackgroundColor",[.6 .8 1]);
 
% Create the widget
listWidget2 = wt.ListSelectorTwoPane(gridObj);
listWidget2.Items = ["California","Massachusetts","Michigan","Texas"];
listWidget2.Value = ["Massachusetts","Michigan"];

Password Field

% Create a figure with a grid layout
figObj = uifigure("Position",[100 100 250 45]);
gridObj = uigridlayout(figObj,[1 2],"BackgroundColor",[.6 .8 1]);
gridObj.ColumnWidth = {'fit','1x'};
 
% Add label
uilabel(gridObj,"Text","Password:");
This component won't show in the preview, but it will create a password field with text displayed as dots.
% Create the widget
passwordWidget = wt.PasswordField(gridObj);
 
% Configure the widget
passwordWidget.Value = "MathWorks";

Progress Bar

% Create a figure with a grid layout
figObj = uifigure("Position",[100 100 300 60]);
gridObj = uigridlayout(figObj,[1 1],"BackgroundColor",[.6 .8 1]);
 
% Create the widget
progressWidget = wt.ProgressBar(gridObj);
 
% Configure the widget
progressWidget.ShowCancel = true;
 
% Assign a callback
progressWidget.CancelPressedFcn = @(h,e)disp("Cancel Pressed!")
progressWidget =
ProgressBar with properties: ShowTimeRemaining: on ShowCancel: on @@ -134,7 +134,7 @@ Position: [100 100 100 100] Show all properties -
 
% Start the progress bar
progressWidget.startProgress("The task is starting...");
 
% Wait some time to simulate a running task
pause(2)
 
% Update the task progress
progressWidget.setProgress(0.5, "The task is running...");
Then, when the task is done:
% Mark the task finished
progressWidget.finishProgress("The task is finished");
If you want an indeteriminate progress bar:
% Mark the task finished
progressWidget.Indeterminate = true;
 
% Start the progress bar
progressWidget.startProgress("The task is running...");

Slider Checkbox Combination Group

% Create a figure with a grid layout
figObj = uifigure("Position",[100 100 250 125]);
gridObj = uigridlayout(figObj,[1 1],"BackgroundColor",[.6 .8 1]);
 
% Create the widget
sliderCheckboxWidget = wt.SliderCheckboxGroup(gridObj);
 
% Configure the widget
sliderCheckboxWidget.Name = ["Red", "Green", "Blue", "Alpha"];
sliderCheckboxWidget.CheckboxWidth = 100
sliderCheckboxWidget =
SliderCheckboxGroup with properties: +
 
% Start the progress bar
progressWidget.startProgress("The task is starting...");
 
% Wait some time to simulate a running task
pause(2)
 
% Update the task progress
progressWidget.setProgress(0.5, "The task is running...");
Then, when the task is done:
% Mark the task finished
progressWidget.finishProgress("The task is finished");
If you want an indeteriminate progress bar:
% Mark the task finished
progressWidget.Indeterminate = true;
 
% Start the progress bar
progressWidget.startProgress("The task is running...");

Slider Checkbox Combination Group

% Create a figure with a grid layout
figObj = uifigure("Position",[100 100 250 125]);
gridObj = uigridlayout(figObj,[1 1],"BackgroundColor",[.6 .8 1]);
 
% Create the widget
sliderCheckboxWidget = wt.SliderCheckboxGroup(gridObj);
 
% Configure the widget
sliderCheckboxWidget.Name = ["Red", "Green", "Blue", "Alpha"];
sliderCheckboxWidget.CheckboxWidth = 100
sliderCheckboxWidget =
SliderCheckboxGroup with properties: Name: ["Red" "Green" "Blue" "Alpha"] State: [1 1 1 1] @@ -145,7 +145,7 @@ Position: [100 100 100 100] Show all properties -
sliderCheckboxWidget.Value = [0.8, 0.3, 0, 1];
sliderCheckboxWidget.State = [true, true, false, true];
 
% Assign a callback
sliderCheckboxWidget.ValueChangedFcn = @(src,evt)disp(evt)
sliderCheckboxWidget =
SliderCheckboxGroup with properties: +
sliderCheckboxWidget.Value = [0.8, 0.3, 0, 1];
sliderCheckboxWidget.State = [true, true, false, true];
 
% Assign a callback
sliderCheckboxWidget.ValueChangedFcn = @(src,evt)disp(evt)
sliderCheckboxWidget =
SliderCheckboxGroup with properties: Name: ["Red" "Green" "Blue" "Alpha"] State: [1 1 0 1] @@ -156,7 +156,7 @@ Position: [11 11 230 105] Show all properties -

Slider Spinner Combination

% Create a figure with a grid layout
figObj = uifigure("Position",[100 100 250 70]);
gridObj = uigridlayout(figObj,[1 1],"BackgroundColor",[.6 .8 1]);
 
% Create the widget
sliderSpinnerWidget = wt.SliderSpinner(gridObj);
 
% Configure the widget
sliderSpinnerWidget.Limits = [-10 30];
sliderSpinnerWidget.RoundFractionalValues = "off";
sliderSpinnerWidget.Step = 0.5;
sliderSpinnerWidget.Value = 16.5;
 
% Assign a callback
sliderSpinnerWidget.ValueChangedFcn = @(src,evt)disp(evt)
sliderSpinnerWidget =
SliderSpinner with properties: +

Slider Spinner Combination

% Create a figure with a grid layout
figObj = uifigure("Position",[100 100 250 70]);
gridObj = uigridlayout(figObj,[1 1],"BackgroundColor",[.6 .8 1]);
 
% Create the widget
sliderSpinnerWidget = wt.SliderSpinner(gridObj);
 
% Configure the widget
sliderSpinnerWidget.Limits = [-10 30];
sliderSpinnerWidget.RoundFractionalValues = "off";
sliderSpinnerWidget.Step = 0.5;
sliderSpinnerWidget.Value = 16.5;
 
% Assign a callback
sliderSpinnerWidget.ValueChangedFcn = @(src,evt)disp(evt)
sliderSpinnerWidget =
SliderSpinner with properties: Value: 16.5 Limits: [-10 30] @@ -177,7 +177,7 @@ Position: [11 11 230 50] Show all properties -

Task Status Table

% Create a figure with a grid layout
figObj = uifigure("Position",[100 100 250 225]);
gridObj = uigridlayout(figObj,[1 1],"BackgroundColor",[.6 .8 1]);
 
% Create the widget
taskStatusWidget = wt.TaskStatusTable(gridObj);
 
% Configure the widget
taskStatusWidget.Items = [
"Import Data"
"Preprocess Data"
"Analyze Data"
"Plot Results"
"Save Results"
];
taskStatusWidget.Status = [
"complete"
"warning"
"running"
"none"
"none"
];
taskStatusWidget.SelectedIndex = 3;
 
% Assign a callback
taskStatusWidget.ButtonPushedFcn = @(src,evt)disp(evt)
taskStatusWidget =
TaskStatusTable with properties: +

Task Status Table

% Create a figure with a grid layout
figObj = uifigure("Position",[100 100 250 225]);
gridObj = uigridlayout(figObj,[1 1],"BackgroundColor",[.6 .8 1]);
 
% Create the widget
taskStatusWidget = wt.TaskStatusTable(gridObj);
 
% Configure the widget
taskStatusWidget.Items = [
"Import Data"
"Preprocess Data"
"Analyze Data"
"Plot Results"
"Save Results"
];
taskStatusWidget.Status = [
"complete"
"warning"
"running"
"none"
"none"
];
taskStatusWidget.SelectedIndex = 3;
 
% Assign a callback
taskStatusWidget.ButtonPushedFcn = @(src,evt)disp(evt)
taskStatusWidget =
TaskStatusTable with properties: Items: [5×1 string] Status: [5×1 wt.enum.StatusState] @@ -192,7 +192,7 @@ Position: [11 11 230 205] Show all properties -

Toolbar

Horizontal Sections

% Create a figure with a grid layout
figObj = uifigure("Position",[100 100 350 120]);
gridObj = uigridlayout(figObj,[1 1],"BackgroundColor",[.6 .8 1]);
 
% Create the widget
toolbarWidget1 = wt.Toolbar(gridObj);
 
% Create a horizontal section
section1 = wt.toolbar.HorizontalSection();
section1.Title = "NORMAL BUTTONS";
section1.addButton("open_24.png", "Open");
section1.addButton("save_24.png", "Save");
 
% Create a horizontal section with state buttons
section2 = wt.toolbar.HorizontalSection();
section2.Title = "STATE BUTTONS";
stateButton1 = section2.addStateButton("","Mode 1");
stateButton2 = section2.addStateButton("","Mode 2");
stateButton3 = section2.addStateButton("","Mode 3");
 
% Set the state of the buttons
stateButton1.Value = true;
stateButton2.Value = false;
stateButton3.Value = false;
 
% Attach the horizontal sections to the toolbar
toolbarWidget1.Section = [
section1
section2
];
 
% Assign a callback
toolbarWidget1.ButtonPushedFcn = @(src,evt)disp(evt)
toolbarWidget1 =
Toolbar with properties: +

Toolbar

Horizontal Sections

% Create a figure with a grid layout
figObj = uifigure("Position",[100 100 350 120]);
gridObj = uigridlayout(figObj,[1 1],"BackgroundColor",[.6 .8 1]);
 
% Create the widget
toolbarWidget1 = wt.Toolbar(gridObj);
 
% Create a horizontal section
section1 = wt.toolbar.HorizontalSection();
section1.Title = "NORMAL BUTTONS";
section1.addButton("open_24.png", "Open");
section1.addButton("save_24.png", "Save");
 
% Create a horizontal section with state buttons
section2 = wt.toolbar.HorizontalSection();
section2.Title = "STATE BUTTONS";
stateButton1 = section2.addStateButton("","Mode 1");
stateButton2 = section2.addStateButton("","Mode 2");
stateButton3 = section2.addStateButton("","Mode 3");
 
% Set the state of the buttons
stateButton1.Value = true;
stateButton2.Value = false;
stateButton3.Value = false;
 
% Attach the horizontal sections to the toolbar
toolbarWidget1.Section = [
section1
section2
];
 
% Assign a callback
toolbarWidget1.ButtonPushedFcn = @(src,evt)disp(evt)
toolbarWidget1 =
Toolbar with properties: Section: [2×1 HorizontalSection] DividerColor: [0.94 0.94 0.94] @@ -200,7 +200,7 @@ Position: [100 100 100 100] Show all properties -

Toolbar

Vertical sections

% Create a figure with a grid layout
figObj = uifigure("Position",[100 100 375 130]);
gridObj = uigridlayout(figObj,[1 1],"BackgroundColor",[.6 .8 1]);
 
% Create the widget
toolbarWidget2 = wt.Toolbar(gridObj);
 
% Create a horizontal section with vertical subsection
section3 = wt.toolbar.HorizontalSection();
section3.Title = "MIXED HORIZONTAL / VERTICAL";
section3.addButton("left_24.png","");
section3.addButton("right_24.png","");
 
% Create the vertical subsection
section3v1 = section3.addVerticalSection();
section3v1.addButton("play_24.png","Play");
section3v1.addButton("stop_24.png","Stop");
 
% Add a manual component to the vertical section
sliderObj = uislider("Parent",[]);
section3v1.Component(end+1) = sliderObj;
 
% Attach a callback to the slider
% This is required for manually adding components
sliderObj.ValueChangedFcn = @(src,evt)disp(evt);
 
% Create more horizontal items
section3.addButton("pause_24.png","Pause");
 
% Add another basic section
section4 = wt.toolbar.HorizontalSection();
section4.Title = "HELP";
section4.addButton('help_24.png','Help');
 
% Attach the horizontal sections to the toolbar
toolbarWidget2.Section = [
section3
section4
];
 
% Assign a callback
toolbarWidget2.ButtonPushedFcn = @(src,evt)disp(evt)
toolbarWidget2 =
Toolbar with properties: +

Toolbar

Vertical sections

% Create a figure with a grid layout
figObj = uifigure("Position",[100 100 375 130]);
gridObj = uigridlayout(figObj,[1 1],"BackgroundColor",[.6 .8 1]);
 
% Create the widget
toolbarWidget2 = wt.Toolbar(gridObj);
 
% Create a horizontal section with vertical subsection
section3 = wt.toolbar.HorizontalSection();
section3.Title = "MIXED HORIZONTAL / VERTICAL";
section3.addButton("left_24.png","");
section3.addButton("right_24.png","");
 
% Create the vertical subsection
section3v1 = section3.addVerticalSection();
section3v1.addButton("play_24.png","Play");
section3v1.addButton("stop_24.png","Stop");
 
% Add a manual component to the vertical section
sliderObj = uislider("Parent",[]);
section3v1.Component(end+1) = sliderObj;
 
% Attach a callback to the slider
% This is required for manually adding components
sliderObj.ValueChangedFcn = @(src,evt)disp(evt);
 
% Create more horizontal items
section3.addButton("pause_24.png","Pause");
 
% Add another basic section
section4 = wt.toolbar.HorizontalSection();
section4.Title = "HELP";
section4.addButton('help_24.png','Help');
 
% Attach the horizontal sections to the toolbar
toolbarWidget2.Section = [
section3
section4
];
 
% Assign a callback
toolbarWidget2.ButtonPushedFcn = @(src,evt)disp(evt)
toolbarWidget2 =
Toolbar with properties: Section: [2×1 HorizontalSection] DividerColor: [0.94 0.94 0.94]