주요 콘텐츠

getCallbackAnnotation

R2026b

Get annotation executing callback

Description

annotationObj = getCallbackAnnotation gets the Simulink.Annotation object of the annotation from which a callback was invoked.

example

Examples

collapse all

Suppose you have a loaded model named myModel. Add an annotation that displays a value of 1 and increments the displayed value by 0.1 every time you click the annotation.

Create an annotation that displays a value of 1.

myAnnotation = Simulink.Annotation("myModel/1");

Assign a click function to the annotation that increments the displayed value by 0.1 every time you click the annotation. To identify the clicked annotation within the click function, use the getCallbackAnnotation function. To get the annotation text, use the dot notation a.Text, where a is the variable storing the Simulink.Annotation object.

myAnnotation.ClickFcn = ...
['a=getCallbackAnnotation; currentText=a.Text; currentVal=str2num(currentText); ',...
'newVal=currentVal+0.1; newText=num2str(newVal); a.Text=newText'];

Output Arguments

collapse all

Annotation from which callback was invoked, returned as a Simulink.Annotation object.

Version History

Introduced before R2006a