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

조회 수: 96 (최근 30일)
Björn Bobe
Björn Bobe 2015년 10월 28일
댓글: Abhijit Sahoo 2022년 2월 10일
Hello,
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
end
end
end

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).
Titus
  댓글 수: 2
Björn Bobe
Björn Bobe 2015년 10월 28일
Hi Titus, thanks for the fast answer. This is exactly what I am doing and inside this callback I would like to call the function which is behind the mask "Apply" button (most bottom right), respectively to check if the GUI has unapplied changes.
But i do not know the function calls.
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:
save_system('Autonomous_Dynamic_Model_Sim3');
  댓글 수: 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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Simulink에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by