Disable and Hide Model Editor Menu Items

About Disabling and Hiding Model Editor Menu Items

You can disable or hide items that appear on the Simulink® Editor menus. To disable or hide a menu item, you must:

Example: Disabling the New Model Command on the Simulink Editor's File Menu

function sl_customization(cm)
  cm.addCustomFilterFcn('Simulink:NewModel',@myFilter);
end

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

Creating a Filter Function

Your filter function must accept a callback info object and return the state that you want to assign to the menu item. Valid states are

  • 'Hidden'

  • 'Disabled'

  • 'Enabled'

Your filter function may have to compete with other filter functions and with Simulink itself to assign a state to an item. Who 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 the item, it is 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. The 'Disabled' state is of middling strength. It overrides 'Enabled' but is itself overridden by 'Hidden'. For example, if any filter function or Simulink or Stateflow assigns 'Disabled' to a menu item and none assigns 'Hidden' to the item, the item is disabled.

Note

The Simulink software does not allow you to filter some menu items, for example, the Exit MATLAB item on the Simulink File menu. An error message is displayed if you attempt to filter a menu item that you are not allowed to filter.

Registering a Filter Function

Use the customization manager's addCustomFilterFcn method to register a filter function. The addCustomFilterFcn method takes two arguments: a tag that identifies the menu or menu item to be filtered (see Displaying Menu Tags) 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 File menu.

function sl_customization(cm)
  cm.addCustomFilterFcn('Simulink:NewModel',@myFilter);
end

Related Topics