How to programmatically "click" the block mask Apply or OK button.
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have created a Block Mask with a Text area. A callback is writing a text to this Text area using set_param(gcb,'VariableText_', 'A little house');
The text is written into the Text Area and clicking the Apply button will save the text. That works Ok, off cause.
What I want to do, and is not able to figure out, is how I programmatically can "click" the Apply or the OK button from the callback?
The purpose is to save the contents of the Text area programmatically.
People have been asking this question before, but I have not found any useful answer.
7 commentaires
Maximilian Panzik
le 17 Sep 2020
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
Réponses (1)
Fangjun Jiang
le 17 Sep 2020
I don't understand the problem.
If the block has a mask of a text area, when user opens the mask by double_clicking the block, the block dialog window opens, the user can type in any text, then, the user can click the "Apply" or "Ok" button, the text is saved with the block.
Running the command "set_param(gcb,'VariableText_', 'A little house')" will do the same. The text 'A little house' is saved with the block afterwards, without the need to worry about clicking the "Apply" or "Ok" button.
0 commentaires
Voir également
Catégories
En savoir plus sur Interactive Model Editing dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!