Main Content

getCallbackAnnotation

Get annotation executing callback

Description

example

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.

Examples

collapse all

This example shows how to invoke a callback using an annotation click function. In the example, you change the parameter value of a block to the value shown on an annotation.

Open the example. Then, open the vdp model.

open_system('vdp')

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

an1 = Simulink.Annotation('vdp/0');
an1.position = [50,250];
an2 = Simulink.Annotation('vdp/2');
an2.position = [100,250];

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 gain parameter of the masked Subsystem block named 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 value on the masked Subsystem block named Mu changes to the number shown on the annotation.

Output Arguments

collapse all

Annotation, returned as a Simulink.Annotation instance.

Version History

Introduced before R2006a