Main Content

Customize System Object Dialog Box Using Mask Editor

The Mask Editor provides a robust way of customizing a System Object dialog box. To employ the use of the Mask Editor, you must first define block parameters in a System Object file. On launch from the System Object toolstrip, Mask Editor pre-populates block parameters from the System Object file. You cannot add or delete block parameters from the Mask Editor.

In the Mask Editor, you can use a rich set of graphical controls such as buttons, list control, images or hyperlinks to enhance a dialog box. You can change the value, position, layout, prompt, and properties of existing block parameters. You can change the type of a block parameter to a compatible type.

Build System Object Dialog Box Using Mask Editor

Follow these steps to create a dialog box for the MATLAB System block using the Mask Editor.

Initialize Block Parameters in System Object File

This example customizes the dialog box for a MATLAB System block called MaskEditorDialogBox. To begin with, you must initialize block parameters in the System Object class of MaskEditorDialogBox to later edit in the Mask Editor.

classdef MaskEditorDialogBox < matlab.System
    % Initialize block dialog parameters.
    
    % Public, tunable properties
    properties
        %InitialTestValue Initial Test Value
        InitialTestValue = 0
        
        %FinalTestValue Final Test Value
        FinalTestValue = 32
        
        UpperLimit = 10
        
        %LowerLimit Lower Limit
        LowerLimit = 4
    end

    % Public Nontunable 
    properties(Nontunable)
        %IC1 First initial condition
        IC1 = 0
        
        %IC2 Second initial condition
        IC2 = 40
        
        %IC3 Third initial condition
        IC3 = 95

        %EnforceUpperLimit Enforce Upper Limit
        EnforceUpperLimit (1,1) logical = true
    end
end

Run the following commands to open the dialog box resulting from the code.

load_system('MaskEditorBlockDialog')
open_system('MaskEditorBlockDialog/MATLAB System')

Launch Mask Editor

Keep the dialog box for the MaskEditorDialogBox block open so that you can refer to it while making changes in the Mask Editor. You can also click the System Block > Launch Mask Editor > Parameters and Dialog > Preview Dialog button from the System Object toolstrip to view the dialog box as it stands currently.

Launch the Mask Editor in one of three ways.

  • Select System Block > Launch Mask Editor from the System object toolstrip.

  • Right-click the corresponding MATLAB System block and select Mask > Edit Mask.

  • Select the corresponding MATLAB System block and press Ctrl + M.

The Mask Editor displays the parameters initialized in the MaskEditorDialogBox System object class. Change the appearance of the dialog box from the Mask Editor in one of the following ways.

  • Create a new tab container.

  • Move parameters between containers.

  • Change the layout of parameters.

  • Change parameter type.

  • Change the prompts for parameters and containers.

In addition, you can also add other display widgets such as buttons, list control, images, or hyperlinks to a dialog box. These widgets are not dependent on block parameters.

Create a New Tab Container

In the Mask Editor, create a new tab called Additional Properties above the existing Parameters group box container:

  • Navigate to the Parameters and Dialog pane of the Mask Editor.

  • Drag the Tab Container control from the Container pane on the left, to the location above the row with the prompt Parameters.

  • A new row is created above the Parameters group box container. Enter the Name as SectionGroup0_Section1.

  • Click on the newly created row and select Tab in the Container pane on the left. A new tab is created within the tab container. In the Prompt column, enter the prompt text as Additional Properties. Enter the Name as Tab1.

  • Press Save Mask and check the dialog box of the block. A new tab with the title Additional Properties is created.

Move Parameters Between Containers

In the Mask Editor, move the existing parameter named EnforceUpperLimit to the newly created tab:

  • Drag the row containing the parameter named EnforceUpperLimit onto the Tab1 row.

  • Release the row containing the EnforceUpperLimit parameter so that it snaps to position below the Tab1 row. Press Save Mask.

  • This action causes the Enforce Upper Limit check box to move to the Additional Properties tab of the dialog box.

Change the Layout of Parameters

In the Mask Editor, change a layout property for the IC3 text box. For example, you can change the location of the text prompt label:

  • Click on the IC3 row in the Parameters and Dialog pane.

  • In the Property Editor pane on the right, under Layout, select top from the Prompt Location list. Press Save Mask.

  • In the dialog box, the Third initial condition: text box label moves from the left of the text box to the top.

Change Parameter Type

In the Mask Editor, change the type of the IC3 text box to dial, and define the minimum and maximum values:

  • Click on the IC3 row in the Parameters and Dialog pane.

  • In the Property Editor pane on the right, under Properties, select dial from the Type list.

  • Enter 0 as the Minimum value and 100 as the Maximum value. Select Linear from the Scale drop-down list. Press Save Mask.

  • In the dialog box, the IC3 text box is converted to a dial with the minimum and maximum values at either end. Choose the required value by rotating the dial.

Change Parameter and Container Prompts

In the Mask Editor, change the prompt of the IC3 text box and the Additional Properties tab to new strings:

  • Double-click on the text in the Prompt column of the Tab1 row in the Parameters and Dialog pane. Edit the prompt text to Additional Conditions.

  • Double-click on the text in the Prompt column of the IC3 row in the Parameters and Dialog pane. Edit the prompt text to Third Condition:

  • The text labels are changed to the new strings in the dialog box.

Migrate Existing Dialog Box Customizations to Mask Editor

If you previously customized your MATLAB System dialog box using the getPropertyGroupsImpl function, then you can migrate all the customizations to the Mask Editor:

  1. Launch the Mask Editor. The Mask Editor displays the most recent dialog controls and layout as programmed in the getPropertyGroupsImpl function.

  2. Continue work on the dialog box customizations, if required.

  3. When done, click Save Mask to complete the migration. On saving the mask, the following changes occur:

  • The getPropertyGroupsImpl function is removed from the body of the System Object file.

  • The dialog customizations of the getPropertyGroupsImpl function are moved to a new XML file with the name format: sysObjectName_mask.xml.

  • The sysObjectName_mask.xml file is stored in the same location as the System Object file.

In this way, the getPropertyGroupsImpl function is migrated to the sysObjectName_mask.xml file. When the Mask Editor is invoked next, Simulink loads all dialog customizations from the sysObjectName_mask.xml file.

Related Topics