How to programmatically "click" the block mask Apply or OK button.

18 Ansichten (letzte 30 Tage)
Petter Gran-Jansen
Petter Gran-Jansen am 20 Jan. 2020
Beantwortet: Fangjun Jiang am 17 Sep. 2020
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 Kommentare
Petter Gran-Jansen
Petter Gran-Jansen am 24 Jan. 2020
Maybe someone from Matlab can contribute to this question, please?
Maximilian Panzik
Maximilian Panzik am 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

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Fangjun Jiang
Fangjun Jiang am 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.

Kategorien

Mehr zu Simulink Functions finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by