How do I disable Simulink Toolstrip Actions in MATLAB R2023b?

1 回表示 (過去 30 日間)
Joseph
Joseph 2023 年 7 月 7 日
編集済み: MathWorks Support Team 2023 年 10 月 26 日
I'm building a GUI for a tool that allows a user to build Simulink system models. I'm creating a Simulink model template to have consistent models built by the user. I'm trying to disable actions in the Simulink toolstrip to avoid the user working outside the GUI. I'm using the article:
as a guide on how to do this but I'm having difficulty getting this to work. I'm confused because in this article, it says "To get the name and icon for a built-in action from the Simulink Toolstrip, use the 'slToolstripDeveloperMode' function." Following the example shown in the article, when I pause and click CTRL over the new model icon, I get:
Action: createNewModelAction
Icon: model
But the example in the article uses the syntax:
function sl_customization(cm)
cm.addCustomFilterFcn('Simulink:NewModel',@myFilter);
end
function state = myFilter(callbackInfo)
state = 'Disabled';
end
This syntax works to Disable the new model button. My question is, why is the syntax 'Simulink:NewModel' and not 'Simulink:createNewModelAction'? What am I missing and how do I find the correct syntax to use for the other actions in the toolstrip?

採用された回答

Deep
Deep 2023 年 10 月 26 日
編集済み: MathWorks Support Team 2023 年 10 月 26 日
The action names that show up in the MATLAB Command Window after you hover over an icon and press CTRL should be used as-is. Note, to turn on this feature, run
>> slToolstripDeveloperMode('on')
In the question proposed, "createNewModelAction" should be passed to the method "addCustomFilterFcn". For example, the following code placed in "sl_customization.m" disables the "Model" icon. 
function sl_customization(cm)
cm.addCustomFilterFcn('createNewModelAction',@myFilter);
end
function state = myFilter(callbackInfo)
state = 'Disabled';
end
Note that while "Simulink:NewModel" works as per the documentation example, this tag name does not follow the action names written in the documentation. The inconsistency in our documentation has been relayed to our development team to consider updating in future releases.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSimulink Environment Customization についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by