Simulink Dialog Callback Executed Only When Dialog Parameter Is Changed

5 views (last 30 days)
I am working on a Simulink model with masked subsystems. Here is my situation: I am using Dialog Callbacks for my masked parameters, but have noticed that a Mask Callback occurs simply by double clicking on the masked block to edit the paramters (found this out by turning on callback tracing). This creates overhead because nothing has changed yet and may not change (simploy by closing the window or clicking cancel). How do I force the Dialog Callback to only fire when I change a dialog parameter value by hitting Apply or OK?

Answers (1)

Doug Eastman
Doug Eastman on 20 Jan 2011
Hi Travis,
For code that you only want to execute when parameters change, you may want to put the code in the Initialization commands section in the Initialization pane.
From the doc:
"Initialization commands for all masked blocks in a model run when you:
  • Update the diagram.
  • Start simulation.
  • Start code generation.
Initialization commands for an individual masked block run when you:
  • Change any of the parameters that define the mask, such as MaskDisplay and MaskInitialization, by using the Mask Editor or set_param.
  • Change the appearance of the masked block, for example by resizing or rotating the block.
  • Change the value of a mask parameter by using the block dialog or set_param.
  • Copy the masked block within the same model or between different models."
Dialog Callback commands are generally intended only to update the dialog display for example by hiding or revealing parameters based on a check box or drop-down menu.
From the Doc: "You can use such [Dialog] callbacks to create dialog boxes that change in appearance depending on the changes the user makes to control settings, such as enabling an edit field when a user selects a check box."

Categories

Find more on Author Block Masks in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!