InteractionState class

Contains all interaction-related state for the node flow editor.

This class manages the state for various user interactions including:

  • Node dragging
  • Connection creation
  • Multi-node selection
  • Mouse cursor state
  • Pan/zoom control

All state is managed using MobX observables for reactive updates. The class provides both low-level observables and high-level convenience getters for accessing state.

Example usage:

final state = InteractionState();

// Check if user is dragging a node
if (state.currentDraggedNodeId != null) {
  // Handle drag
}

// Start a connection
state.update(
  temporaryConnection: TemporaryConnection(
    sourceNodeId: 'node-1',
    sourcePortId: 'port-1',
  ),
);

See also:

Constructors

InteractionState()

Properties

connectionSourceNodeId String?
Gets the source node ID of the temporary connection.
no setter
connectionSourcePortId String?
Gets the source port ID of the temporary connection.
no setter
currentCursor → Observable<MouseCursor>
Observable current mouse cursor.
final
currentDraggedNodeId String?
Gets the ID of the currently dragged node.
no setter
currentPointerPosition Offset?
Gets the current pointer position.
no setter
cursor MouseCursor
Gets the current mouse cursor.
no setter
draggedNodeId → Observable<String?>
Observable ID of the node currently being dragged.
final
hashCode int
The hash code for this object.
no setterinherited
isCreatingConnection bool
Checks if a connection is currently being created.
no setter
isDrawingSelection bool
Checks if a selection rectangle is being drawn.
no setter
isPanEnabled bool
Gets whether panning is enabled.
no setter
lastPointerPosition → Observable<Offset?>
Observable position of the last pointer event.
final
panEnabled → Observable<bool>
Observable flag for whether panning is enabled.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
selectionRectangle → Observable<Rect?>
Observable selection rectangle bounds.
final
selectionStart Offset?
Gets the starting point of the selection rectangle.
no setter
selectionStartPoint → Observable<Offset?>
Observable starting point of a selection rectangle.
final
temporaryConnection → Observable<TemporaryConnection?>
Observable temporary connection being created.
final

Methods

cancelConnection() → void
Cancels the current connection creation.
finishSelection() → void
Finishes the current selection operation.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
resetState() → void
Resets all interaction state to default values.
setDraggedNode(String? nodeId) → void
Sets the currently dragged node.
setPointerPosition(Offset? position) → void
Sets the current pointer position.
toString() String
A string representation of this object.
inherited
update({MouseCursor? cursor, bool? panEnabled, TemporaryConnection? temporaryConnection}) → void
Updates multiple state properties atomically.
updateSelection({Offset? startPoint, Rect? rectangle, List<String>? intersectingNodes, bool? toggle, dynamic selectNodes(List<String>, {bool toggle})?}) → void
Updates selection rectangle state and handles node selection.

Operators

operator ==(Object other) bool
The equality operator.
inherited