Main Content

slCreateToolstripTab

Create custom tab for Simulink Toolstrip

Since R2021b

Description

slCreateToolstripTab(tab,component) creates a blank custom tab in the specified Simulink® Toolstrip component, opens the JSON file that defines the custom tab, and reloads the toolstrip configuration.

example

slCreateToolstripTab(tab,component,Name=Value) sets properties using name-value arguments. For example, slCreateToolstripTab('toolsTab',"custom",Title="Tools") creates a Tools tab.

example

Examples

collapse all

A Simulink Toolstrip component contains the definition for one or more custom tabs. Before you create a custom tab, you must create the component to contain it.

To work with the Simulink Toolstrip, start Simulink. For example, in the MATLAB® Command Window, enter:

start_simulink

Create a custom Simulink Toolstrip component by using the slCreateToolstripComponent function. For example, name the component custom.

slCreateToolstripComponent("custom");

This command creates a resources folder in your current folder and adds your current folder to the MATLAB path. The resources folder contains two folders and one JSON file.

  • icons folder — Location of icons used by custom tab elements

  • json folder — Location of JSON files that define custom tabs

  • sl_toolstrip_plugins.json — JSON file that must not be edited

Create an untitled custom tab with the slCreateToolstripTab function.

For example, create the tab customTab in the custom component.

slCreateToolstripTab("customTab","custom");

The function creates a JSON file in the json folder that contains information about the tab. For example:

{
  "version": "1.0",
  "entries": [
    {
      "type": "Tab",
      "id": "customTab",
      "title": ""
    }
  ]
}

Open a model. For example, open the vdp model.

openExample("simulink_general/VanDerPolOscillatorExample")

The Simulink Toolstrip displays a blank tab without a title.

The new tab appears between the built-in Format and Apps tabs.

A Simulink Toolstrip component contains the definition for one or more custom tabs. Before you create a custom tab, you must create the component to contain it.

To work with the Simulink Toolstrip, start Simulink. For example, in the MATLAB Command Window, enter:

start_simulink

Create a custom Simulink Toolstrip component by using the slCreateToolstripComponent function. For example, name the component custom.

slCreateToolstripComponent("custom");

This command creates a resources folder in your current folder and adds your current folder to the MATLAB path. The resources folder contains two folders and one JSON file.

  • icons folder — Location of icons used by custom tab elements

  • json folder — Location of JSON files that define custom tabs

  • sl_toolstrip_plugins.json — JSON file that must not be edited

Create a custom tab with the slCreateToolstripTab function.

For example, create the tab customTab in the custom component, and title the tab CUSTOM TAB.

slCreateToolstripTab("customTab","custom",Title="CUSTOM TAB");

The function creates a JSON file named customTab.json in the json folder that defines the tab.

Open a model. For example, open the vdp model.

openExample("simulink_general/VanDerPolOscillatorExample")

The Simulink Toolstrip displays a blank tab titled CUSTOM TAB.

The new tab appears between the built-in Format and Apps tabs.

Input Arguments

collapse all

Tab ID, specified as a character vector or string scalar.

The tab ID appears in the JSON file that defines the tab as the value for the id property in the JSON object where "type": "Tab".

Data Types: char | string

Component name, specified as a character vector or string scalar.

The component name appears in the sl_toolstrip_plugins.json file as the value for the Name property. Do not edit this file.

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: slCreateToolstripTab('customTab',"custom",Title="Custom Tab")

Tab title, specified as a character vector or string scalar.

Tab titles use all uppercase letters even when you specify a title with lowercase letters.

The tab title appears in the JSON file that defines the tab as the value for the title property of the JSON object where "type": "Tab".

Data Types: char | string

Name of file that defines the tab, specified as a character vector or string scalar.

Data Types: char | string

Version History

Introduced in R2021b