internalStartAnnotationDrag method

void internalStartAnnotationDrag(
  1. String annotationId,
  2. Offset pointerPosition
)

Implementation

void internalStartAnnotationDrag(
  String annotationId,
  Offset pointerPosition,
) {
  final annotation = _annotations[annotationId];
  if (annotation?.isInteractive == true) {
    runInAction(() {
      _draggedAnnotationId.value = annotationId;
      _lastPointerPosition.value = pointerPosition;
      _annotationCursor.value = SystemMouseCursors.grabbing;

      // IMPORTANT: Always ensure proper selection when dragging starts
      // This handles the case where annotation was selected via Cmd+click with nodes also selected
      if (!_selectedAnnotationIds.contains(annotationId)) {
        // Annotation not selected - select it (this will clear other selections)
        internalSelectAnnotation(annotationId);
      } else {
        // Annotation already selected - but still need to clear other selections for clean drag
        _clearNodeAndConnectionSelections();
      }
    });
  }
}