Main Content


Get annotation executing callback



ann = getCallbackAnnotation gets the annotation from which a callback was invoked. Invoke a callback from an annotation click function. After you get the annotation, you can, for example, get text or parameters from the annotation to use someplace else in your model.

For information on click functions, see Add Hyperlinks to Annotations.


collapse all

Invoke a callback by way of an annotation click function. This example shows how to change a parameter value on a block to the value shown on an annotation.

Open vdp. Add and position two annotations. Each annotation displays a different value.

an1 = Simulink.Annotation('vdp/1');
an1.position = [100,300];
an2 = Simulink.Annotation('vdp/3');
an2.position = [150,300];

Assign a click function to each annotation. The click function uses getAnnotationCallback to get the annotation instance. Get the text from each annotation and use it to set the parameter on the Gain block (Mu).

an1.ClickFcn = 'ann = getCallbackAnnotation; v = ann.Text; set_param(''vdp/Mu'',''Gain'',v)';
an2.ClickFcn = 'ann = getCallbackAnnotation; v = ann.Text; set_param(''vdp/Mu'',''Gain'',v)';

Click each annotation. When you click, the gain value on the Mu block changes to the number shown on the annotation.

Output Arguments

collapse all

Annotation, returned as a Simulink.Annotation instance.

Version History

Introduced before R2006a