Main Content

Disable and Hide Model Editor Items

You can disable items that appear on the Simulink® Toolstrip and context menus. You can also hide items that appear on context menus. To disable or hide an item, you must:

Example: Disable the New Model Command in the Simulink Toolstrip

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

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

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'

  • '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 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 a Filter Function

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)
  cm.addCustomFilterFcn('Simulink:NewModel',@myFilter);
end

Related Topics