Main Content

Disable Simulink Toolstrip and Context Menu Actions

You can disable items that appear in the Simulink® Toolstrip and context menus. For context menus, you can also hide actions. To disable or hide an action, you must:

  1. Get the name of the built-in action that you want to disable or hide.

  2. Create or edit a customization file.

  3. Create a filter function that disables or hides the item.

  4. Register the filter function with the customization manager.

  5. Refresh the Simulink customization file (sl_customization.m).

For example, this code creates and registers a filter function to disable the New Model button in the Simulink Toolstrip.

function sl_customization(cm)

function state = myFilter(callbackInfo)
  state = 'Disabled';

Get Built-In Simulink Actions

To get the name and icon for a built-in action from the Simulink Toolstrip, use the slToolstripDeveloperMode function.

In the MATLAB® Command Window, enter this command:

ans =



The command enables developer mode for the Simulink Toolstrip. The returned value indicates that developer mode was disabled before you entered the command.

Pause on an item in the Simulink Toolstrip and press Ctrl. On a Mac, press command (⌘) instead of Ctrl.

For example, pause on the Open button and press Ctrl.

Action: openModelAction
Icon: open

The names of the corresponding action and icon appear in the MATLAB Command Window.

Set Up Customization File

To register customizations, use a MATLAB function file named sl_customization.m. Place the function on the MATLAB path of the Simulink installation that you want to customize or in the current folder.

You can have more than one sl_customization.m file. The customizations in each file take effect, with conflicts handled by each customization. For example, if you specify priorities for libraries in multiple sl_customization.m files, only one takes effect. If you add the same menu item twice, it appears twice. To ensure that customizations load as expected, refresh the customizations as described in Read and Refresh Customization Files.

The sl_customization function accepts one argument: a handle to the customization manager object (cm). For example:

function sl_customization(cm)

Create Filter Functions

In the sl_customization.m file, create a filter function. Your filter function must accept a callback info object and return the state that you want to assign to the item. Valid states are:

  • 'Hidden' — Hide the item.

  • 'Disabled' — Disable the item.

  • 'Enabled' — Enable the item.

For example, this filter function assigns the 'Disabled' state.

function state = myFilter(callbackInfo)
  state = 'Disabled';

Your filter function may have to compete with other filter functions and with Simulink to assign a state to an item. Which one succeeds depends on the strength of the state that each assigns to the item.

  • 'Hidden' is the strongest state. If any filter function or Simulink assigns 'Hidden' to a menu item, it is hidden. For Simulink Toolstrip items, specifying 'Hidden' disables the item instead of hiding it.

  • 'Disabled' overrides 'Enabled', but is itself overridden by 'Hidden'.

  • 'Enabled' is the weakest state. For an item to be enabled, all filter functions and the Simulink or Stateflow® products must assign 'Enabled' to the item.

Register Filter Functions

Use the customization manager addCustomFilterFcn method to register a filter function. The addCustomFilterFcn method takes two arguments: a tag that identifies the menu or item to be filtered and a pointer to the filter function itself.

For example, the following code registers a filter function for the New Model item on the Simulink Toolstrip.

function sl_customization(cm)

Read and Refresh Customization Files

The sl_customization.m file is read when Simulink starts. If you change the sl_customization.m file, either restart Simulink or enter this command to see the changes:


This command runs all sl_customization.m files on the MATLAB path and in the current folder. Some side effects of running sl_refresh_customizations include:

  • Rebuilding the Simulink Toolstrip

  • Rebuilding all Simulink Editor menus

  • Rebuilding the Library Browser menus and toolbars

  • Clearing the Library Browser cache and refreshing the Library Browser

  • Reloading the Viewers and Generators Manager data

Related Topics