selectAnnotation method
Selects an annotation in the graph.
Automatically clears selections of other element types (nodes, connections). Requests canvas focus.
Triggers the onAnnotationSelected callback after selection changes.
Parameters:
annotationId: The ID of the annotation to selecttoggle: Iftrue, toggles the annotation's selection state. Iffalse(default), clears other selections and selects only this annotation.
Implementation
void selectAnnotation(String annotationId, {bool toggle = false}) {
runInAction(() {
// Clear other element types' selections
clearNodeSelection();
clearConnectionSelection();
});
annotations.selectAnnotation(annotationId, toggle: toggle);
// Fire selection callback with current selection state
final selectedAnnotation = annotations.isAnnotationSelected(annotationId)
? annotations.getAnnotation(annotationId)
: null;
callbacks.onAnnotationSelected?.call(selectedAnnotation);
canvasFocusNode.requestFocus();
}