addDialogControl
Class: Simulink.Mask
Namespace: Simulink
Add dialog control elements to mask dialog box
Syntax
maskObj.addDialogControl(controlType,controlIdentifier)
successIndicator= maskObj.addDialogControl(Name,Value)
Description
maskObj.addDialogControl(
adds dialog control elements like text, hyperlinks, or tabs to mask dialog box. First get the
mask object and assign it to the variable controlType
,controlIdentifier
)maskObj
.
adds dialog control elements specified by one or more successIndicator
= maskObj.addDialogControl(Name,Value
)Name,Value
pair
arguments. You can specify multiple Name-Value pairs.
Input Arguments
controlType
— Value type of dialog control element
panel
| group
| tabcontainer
| tab
| collapsiblepanel
| text
| image
| webbrowser
| pushbutton
| ...
Type of dialog control element, specified as character vector or string
Example: image
Data Types: char
| string
controlIdentifier
— Unique identifier for the element
character vector | string scalar
Programmatic identifier for the element of mask dialog box is specified as a character vector or string. Use a name that is unique and does not have a space between words. For more information, see Variable Names.
Example: maskLink
Data Types: char
| string
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where Name
is
the argument name and Value
is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Example: maskLink =
maskObj.addDialogControl('hyperlink','link');
Type
— Type of dialog control element
empty (default) | panel
| group
| tabcontainer
| tab
| collapsiblepanel
| text
| image
Type of control that is used to specify the value of this dialog control element.
Type is a required argument. The permitted values are 'hyperlink'
,
and 'pushbutton'
.
Example: text
Data Types: char
| string
Name
— Identifier name for the dialog control element
character vector (default) | string
The identifier of the dialog control element specified as a character vector or string. Name is a required argument. This field is available for all dialog control types.
Example: tag
Data Types: char
| string
Prompt
— Display text in the dialog control element
character vector (default) | string
Text that is displayed in the dialog control element on the Mask dialog box specified as a character vector or string. This field is available for all except for panel and image dialog control types.
Example: maskButton.Prompt = 'Compute';
Data Types: char
| string
Tooltip
— Tooltip for the dialog control element
character vector (default) | string
Text that is displayed in the dialog control element on the Mask dialog box. This field is available for all except for panel and image dialog control types.
Example: This is a push button
Data Types: char
| string
Enabled
— Option to specify whether to set the value for the dialog control element or not
on
| off
Option to specify whether you can set value for the dialog control element. This field is available for all dialog control types.
Data Types: logical
Visible
— Hide or Unhide the dialog control element in the dialog box
on
| off
Option to set whether the dialog control element is hidden or visible to the user. This field is available for all dialog control types.
Data Types: logical
Callback
— MATLAB® code that executes when the dialog control element is edited
character vector | string
Container for MATLAB code that executes when you edit the dialog control element and click Apply. This field is available only for the hyperlink and push button dialog control types.
Data Types: char
| string
Row
— Option to set the dialog control in the same row or new row
character vector | string
Option to set whether the dialog control is placed in the new row or the same row. This field is available for all dialog control types.
Data Types: logical
Filepath
— Path to an image file
character vector | string
Contains the path to an image file. This field is available for image, and push button dialog control types.
Data Types: char
| string
Container
— Option to specify container for the child dialog control
character vector | string
Option to specify a container for the child dialog control. The permitted values
are the names of 'panel'
, 'group'
, and
'tab'
dialog controls.
Data Types: logical
Examples
Add Dialog Control Elements to Mask Dialog Box
Get mask object and add dialog control element to it.
% Get mask object on model Engine new_system('Engine'); add_block('built-in/Gain','Engine/gain'); save_system; open_system('Engine'); maskObj = Simulink.Mask.create(gcb); save_system; % Add hyperlink to mask dialog box maskLink = maskObj.addDialogControl('hyperlink','link'); maskLink.Prompt = 'Mathworks Home Page'; maskLink.Callback = 'web(''www.mathworks.com'')'
maskLink = Hyperlink with properties: Name: 'link' Prompt: 'Mathworks Home Page' Callback: 'web('www.mathworks.com')' Row: 'new' Enabled: 'on' Visible: 'on' HorizontalStretch: 'on' Tooltip: ''
% Add text to mask dialog box maskText = maskObj.addDialogControl('text','text_tag'); maskText.Prompt = 'Enable range checking'; % Add button to mask dialog box maskButton = maskObj.addDialogControl('pushbutton','button_tag'); maskButton.Prompt = 'Compute'; save_system;
Add Dialog Control Elements to Mask Dialog Box Tabs
Create tabs on the mask dialog box and add elements to these tabs.
% Get mask object on a block named 'GainBlock' add_block('built-in/Gain','Engine/gain1'); maskObj = Simulink.Mask.create(gcb); maskObj = Simulink.Mask.get(gcb); % Create a tab container maskObj.addDialogControl('tabcontainer','allTabs'); tabs = maskObj.getDialogControl('allTabs'); % Create tabs and name them maskTab1 = tabs.addDialogControl('tab','First'); maskTab1.Prompt = 'First tab'; maskTab2 = tabs.addDialogControl('tab','Second'); maskTab2.Prompt = 'Second tab'; % Add elements to one of the tabs firstTab = tabs.getDialogControl('First'); firstTab.addDialogControl('text','textOnFirst'); firstTab.getDialogControl('textOnFirst').Prompt = 'Tab one'; save_system;
Add Dialog Control Element Using Name-Value Pair
Add dialog control element and specify values for it.
% Get mask object on model Engine add_block('built-in/Gain','Engine/gain2'); maskObj = Simulink.Mask.create(gcb); maskObj = Simulink.Mask.get(gcb); % Add a dialog box and specify values for it maskDialog = maskObj.addDialogControl('Name','abc','Type','text','Prompt','hello','Visible','off'); save_system;
Version History
Introduced in R2014a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)