tjalling
tjalling

Reputation: 523

Programmatically highlight dialog option in Simulink

In Simulink, certain error messages provide clickable links to the origin of the error.

See, for example, the following error:

1]

If I click one of the three links in the message, say, Parent setting, Simulink opens the code generation settings dialog and indicates the specific setting(s) using a blue border:

2]

As a user, can I achieve the same highlighting programmatically (using a .m-script)? If so, how?

Upvotes: 2

Views: 782

Answers (1)

tjalling
tjalling

Reputation: 523

Yes, this is possible, but it requires the use of Simulink internal support functions. Their API is undocumented and may therefore be unstable. Use at your own risk.

The highlighting in the question is achieved as follows:

slprivate('modelref_highlight_configset_setting', 'rtwdemo_capi', 'RTWCAPISignals')

Here,

  • slprivate is a .m-function that ships with Simulink. There is no help entry for the function. Its only mention in the help is on the 'Set Simulink Preferences' help page. Its implementation is simple: it is a wrapper around feval. The implementation can be opened by executing the command >> edit slprivate from the Matlab Command window.

    The function's documentation is as follows:

    slprivate is a gateway for internal support functions used by Simulink.

      VARARGOUT = slprivate('FUNCTION_NAME', VARARGIN)
    
  • In the usage above, the first parameter 'modelref_highlight_configset_setting', is the Simulink internal support function. In this case, it is the function that does the highlighting.

  • The second parameter 'rtwdemo_capi', is the name of the Simulink model whose Configuration Parameters window should be opened for highlighting.
  • The third parameter, 'RTWCAPISignals', is the name of the configuration option to highlight. In this case, that single option highlights two UI elements.

    Names of configuration options can be found as follows:

    1. Open the model's Configuration Parameters window (e.g. in Simulink: menu Simulation -> Model Configuration Parameters, or Ctrl + E)
    2. Right-click on (or, rather, next to) the option
    3. In the context menu that appears, click What's This?
    4. In the help window that appears, scroll down to Command-Line Information. The name of the option is given in the Parameter field.

Edit:

The way I figured this out may be useful for other internal functions, so I'll leave that here as well. If the build is started from the Command Window (>> rtwbuild('rtwdemo_capi')) instead of from the GUI, warning and error messages are printed to the command window as well, including the clickable links. If one then hovers over such a link with the mouse pointer, the corresponding command is shown in the Matlab status bar (at the bottom of the main Matlab window).

Upvotes: 2

Related Questions