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

19 visualizaciones (últimos 30 días)
Petter Gran-Jansen
Petter Gran-Jansen el 20 de En. de 2020
Respondida: Fangjun Jiang el 17 de Sept. de 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 comentarios
Petter Gran-Jansen
Petter Gran-Jansen el 24 de En. de 2020
Maybe someone from Matlab can contribute to this question, please?
Maximilian Panzik
Maximilian Panzik el 17 de Sept. de 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

Iniciar sesión para comentar.

Respuestas (1)

Fangjun Jiang
Fangjun Jiang el 17 de Sept. de 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.

Categorías

Más información sobre Simulink Functions en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by