Dynamically populating mask parameter popup list
14 ビュー (過去 30 日間)
表示 古いコメント
Is it possible to dynamically populate a Simulink mask's popup parameter's list using Dialog callback? Or is this facility static and to be defined while editing the mask?
採用された回答
その他の回答 (2 件)
Kaustubha Govind
2013 年 8 月 14 日
I'm not much of an expert in the Simulink Mask area, but I don't think you can dynamically change the contents of a mask. However, you can change the visibility of parameters - so you might want to create multiple popup lists for each configuration and change their visibility in the Dialog Callback.
2 件のコメント
Matthew
2016 年 11 月 18 日
編集済み: Matthew
2016 年 11 月 18 日
It turns out there is a simple DAStudio functionality that allows masks to be dynamic once open.
dToolRoot = DAStudio.ToolRoot;
openDialogs = dToolRoot.getOpenDialogs;
openDialogs(1).refresh();
Or
blockObject = get_param(gcb,'object');
blockDialog = DAStudio.Dialog(blockObject.getDialogSource);
blockDialog.refresh();
I'll add a full code sample as an answer.
Matthew
2016 年 11 月 18 日
編集済み: Matthew
2016 年 11 月 18 日
If you want to update a popdown menu while a mask is open, the following may be helpful:
% Set the parameter index equal to the index specified
% for the desired popup parameter in the mask editor
parameterIndex = 1;
% Get the handle to the mask parameter to modify
maskHandle = Simulink.Mask.get(gcb);
maskParameters = maskHandle.Parameters;
% Update the popup list options
maskParameters(parameterIndex).TypeOptions = {'Option 1', 'Option 2'};
% Now refresh the mask display
%Get the handle to the blocks object
blockObject=get_param(gcb,'object');
%Get the handle to the dialog
blockDialog= DAStudio.Dialog(blockObject.getDialogSource);
%Refresh the dialog
blockDialog.refresh();
0 件のコメント
参考
カテゴリ
Find more on Simulink Environment Customization in Help Center and File Exchange
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!