addDialogControl

Class: Simulink.dialog.Container
Package: Simulink.dialog

Add dialog control elements to mask dialog box

Description

example

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

example

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 Pair 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'. If the parent dialog control type is 'tabcontainer', the child dialog control must be 'tab'.

'Name'

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

'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

'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 specifies a container for the child dialog control. The permitted values are the names of 'panel', 'group', and 'tab' dialog controls.

Examples

expand all

Get mask object and add dialog control element to it.

% Get mask object on model Engine

maskObj = Simulink.Mask.get('Engine/Gain');

% Add hyperlink to mask dialog box

maskLink = maskObj.addDialogControl('hyperlink','link'); 
maskLink.Prompt = 'Mathworks Home Page';
maskLink.Callback = 'web(''www.mathworks.com'')'

% Alternative method to add hyperlink

maskLink = maskObj.addDialogControl('hyperlink','link'); 
maskLink.Prompt = 'www.mathworks.com';

% 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';

Create tabs on the mask dialog box and add elements to these tabs.

% Get mask object on a block named 'GainBlock'

maskObj = Simulink.Mask.get('GainBlock/Gain');

% 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';

Add dialog control element and specify values for it

% Get mask object on model Engine

maskObj = Simulink.Mask.get('Engine/Gain');

% Add a dialog box and specify values for it

maskDialog = maskObj.addDialogControl('Type','text',...
'Prompt','hello','Visible','off');
Introduced in R2014a