Make an Annotation Interactive

Annotation Callback Functions

You can make an annotation interactive by adding a callback. For example, you can use an annotation click-callback function to open related models from an annotation.

You can associate the following callback functions with annotations.

Click Function

A click function is a MATLAB® function that Simulink® invokes when you click an annotation. You can associate a click function with any model annotation.

You can use click functions to add custom command buttons to a model. For example, a click function can display the values of workspace variables referenced by the model or to open related models.

Simulink uses the color blue for an annotations associated with a click function.

Load Function

Simulink invokes this function when you load the model that contains the associated annotation. To associate a load function with an annotation, set the LoadFcn property of the annotation to the desired function (see Annotations API).

Delete Function

This function is invoked before deleting the associated annotation. To associate a delete function with an annotation, set the DeleteFcn property of the annotation to the desired function (see Annotations API).

Associate Click Functions with Annotations

To associate a click function with an annotation, use one of these approaches:

  • Specify the annotation itself as the click function.

  • Specify a separately defined click function.

To specify the annotation itself as the click function:

  1. Click in the annotation and select Diagram > Properties.

  2. In the Annotation Properties dialog box ClickFcn area, select Use display text as click callback.

To specify a separately-defined click function:

  1. Right-click the annotation border and select Properties.

  2. Click the ClickFcn tab.

  3. In text box below Use display text as click callback, enter the MATLAB code that defines the click function.

    Note:   You can also use MATLAB code to associate a click function with an annotation. See Annotations API for more information.

Select and Edit Click-Function Annotations

If you associate an annotation with a click function, then you cannot select the annotation by clicking it. Instead, use a boundary box to select the annotation.

Similarly, you cannot edit the annotation text by clicking on the text. To edit the annotation:

  1. Use a boundary box to select the annotation

  2. Right-click the selected annotation.

  3. In the context menu, select Properties.

  4. In the Properties dialog box, in the Text field, edit the text.

More About

Was this topic helpful?