How to disable an action button programmatically in Simulink mask?

조회 수: 17 (최근 30일)
Damien
Damien 2016년 10월 20일
편집: Matthew 2016년 11월 22일
Hello, I'm actually looking for disable a button in a mask under conditions, it works well with parameters with the following code but when it is a button it doesn't work.
Name=get_param(gcb,'ModelName');
if strcmp(Name,'User defined')
set_param(gcb,'MaskEnables',{'on','on'});
else
set_param(gcb,'MaskEnables',{'on','off'};
end
My block has two parameters, the first one is called 'ModelName', it is a 'Popup' parameter with some names and one is 'User defined'. The second is currently an 'Edit' parameter but I want to change it or add a 'Button' action and enable it only if 'User defined' is selected.
Thanks for your help.
  댓글 수: 2
Gareth Lee
Gareth Lee 2016년 10월 20일
can you show the diagram corresponding to block and mask interface(include the segment code)
Damien
Damien 2016년 10월 21일
There is nothing to show, I just want to know how to disable a button, I can do it with parameters but not with buttons.

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

답변 (1개)

Matthew
Matthew 2016년 11월 22일
편집: Matthew 2016년 11월 22일
Here's a method
maskHandle = Simulink.Mask.get(gcb);
buttonHandle = maskHandle.getDialogControl('myButtonName');
buttonHandle.Enabled = 'off';
Thanks to John D. in this answer for the the way to get the button handle.

카테고리

Help CenterFile Exchange에서 Programmatic Model Editing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by