Main Content

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(controlType,controlIdentifier) adds dialog control elements like text, hyperlinks, or tabs to mask dialog box. First get the mask object and assign it to the variable maskObj.

successIndicator= maskObj.addDialogControl(Name,Value) adds dialog control elements specified by one or more Name,Value pair arguments. You can specify multiple Name-Value pairs.

Input Arguments

expand all

Type of dialog control element, specified as character vector or string

Example: image

Data Types: char | string

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 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

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

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

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

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

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

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

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

Contains the path to an image file. This field is available for image, and push button dialog control types.

Data Types: char | 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

expand all

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