Main Content

slCreateToolstripComponent

Create custom Simulink Toolstrip component

Description

example

slCreateToolstripComponent(component) creates a resources folder for a custom Simulink® Toolstrip component in the current folder and adds the current folder to the MATLAB® path.

example

slCreateToolstripComponent(component,Name=Value) sets properties using name-value arguments. For example, slCreateToolstripComponent("custom",Location="B:\path\customtab") creates the resources folder for a component named custom in the B:\path\customtab directory and adds B:\path\customtab to the MATLAB path.

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

By default, Simulink Toolstrip components persist across sessions. You can create a temporary Simulink Toolstrip component that persists only during the current session.

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

slCreateToolstripComponent("temp",Persist=false);

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

When you open a new MATLAB session, the temp component is not loaded.

Input Arguments

collapse all

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.

Example: slCreateToolstripComponent("custom")

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: slCreateToolstripComponent("custom",Location="B:\path\customtab",Persist=false)

Storage location for component files, specified as a character vector or string scalar. The function adds the storage location to the MATLAB path.

By default, the function generates the component files in a resources folder in the current folder.

Example: slCreateToolstripComponent("custom",Location="B:\path\customtab")

Data Types: char | string

Option to load component for new MATLAB sessions, specified as a numeric or logical 1 (true) or 0 (false).

Example: slCreateToolstripComponent("custom",Persist=false)

Data Types: double | logical

Introduced in R2021b