How to apply/check changes in a Simulink Mask via callback?

95 ビュー (過去 30 日間)
Björn Bobe
Björn Bobe 2015 年 10 月 28 日
コメント済み: Abhijit Sahoo 2022 年 2 月 10 日
At the moment i am going to set up Simulink block mask, which is changing the content of popup elements due to entries inside an edit field. Therefore I need to know, how to "press" the Apply button of the Mask-GUI via script, respectively how to check if the GUI has unapplied changes.
I am using Matlab Simulink 2013b.
Thanks in advance, Bjoern

回答 (3 件)

Maximilian Panzik
Maximilian Panzik 2020 年 9 月 17 日
A bit late but maybe this helps somebody:
selected_block_handle = get_param(gcb,'Handle');
dlgs = DAStudio.ToolRoot.getOpenDialogs;
for i=1:length(dlgs) %find dialog of selected block
if class(dlgs(i).getSource) == "Simulink.SLDialogSource"
dialog_block_handle = dlgs(i).getSource.getBlock.Handle;
if dialog_block_handle == selected_block_handle
dlgs(i).apply %'click' apply

Titus Edelhofer
Titus Edelhofer 2015 年 10 月 28 日
Hi Bjoern,
when the user presses enter after editing the field, the MaskCallback is executed. This is the callback in which you should validate what the user entered (and do the manipulations you describe).
  2 件のコメント
Abhijit Sahoo
Abhijit Sahoo 2022 年 2 月 10 日
thank you Björn Bobe, it worked for me.


Kurt Stewart
Kurt Stewart 2019 年 1 月 14 日
HI Bjorn,
The way you can do this is save your model in MATLAB before running the model:
  1 件のコメント
Bill Tubbs
Bill Tubbs 2020 年 7 月 16 日
This solution didn't work for me. Even pressing 'save' in Simulink didn't solve it. I had to manually go into the model and find the block I had edited and press the 'Apply' button. Then it would run from MATLAB.


Community Treasure Hunt

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

Start Hunting!

Translated by