clearSelection method

void clearSelection()

Clears all selections (nodes, connections, and annotations) and exits any active editing mode.

This is a convenience method that calls clearNodeSelection, clearConnectionSelection, clearAnnotationSelection, and clearAnnotationEditing.

Implementation

void clearSelection() {
  runInAction(() {
    // Always clear editing state (even if nothing is selected)
    annotations.clearAnnotationEditing();

    // Only clear selections if something is selected
    if (_selectedNodeIds.isNotEmpty ||
        _selectedConnectionIds.isNotEmpty ||
        annotations.hasAnnotationSelection) {
      clearNodeSelection();
      clearConnectionSelection();
      annotations.clearAnnotationSelection();
    }
  });
}