Main Content

addDialogControl

Class: Simulink.Mask
Package: Simulink

Add dialog control elements to mask dialog box

Description

successIndicator = 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) specifies the Name and Value arguments for an element on the mask dialog box. You can specify multiple Name-Value pairs.

Input Arguments

expand all

Type of dialog control element, specified

  • 'panel'

  • 'group'

  • 'tabcontainer'

  • 'tab'

  • 'collapsiblepanel'

  • 'text'

  • 'image'

  • 'hyperlink'

  • 'pushbutton'

Specifies the programmatic identifier for the element of mask dialog box. Use a name that is unique and does not have space between words. For more information, see Variable Names.

Name-Value Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' ') and is case-sensitive. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Type

Type of control that is used to specify the value of this dialog control element. Type is a required argument. The permitted values are 'panel', 'group', 'tabcontainer', 'tab', 'collapsiblepanel', 'text', 'image', 'hyperlink', and 'pushbutton'.

Default: empty

Name

The identifier of the dialog control element. Name is a required argument. This field is available for all dialog control types.

Default: empty

Prompt

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.

Default: empty

Tooltip

Tooltip for the dialog control element.

Default: empty

Enabled

Option to specify whether you can set value for the dialog control element. This field is available for all dialog control types.

Default: 'on'

Visible

Option to set whether the dialog control element is hidden or visible to the user. This field is available for all dialog control types.

Default: 'on'

Callback

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 pushbutton dialog control types.

Default: empty

Row

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.

Default: empty

Filepath

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

Default: empty

Container

Option to specify a container for the child dialog control. The permitted values are the names of 'panel', 'group', and 'tab' dialog controls.

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);
maskObj = Simulink.Mask.get(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