Skip to main content

Module drag

Module drag 

Source
Expand description

Drag-and-drop protocol: Draggable sources, DropTarget targets, and DragPayload. Drag-and-drop protocol (bd-1csc.1 + bd-1csc.2).

Defines the Draggable trait for drag sources and DropTarget trait for drop targets, along with DragPayload for transferring typed data, DragState for tracking active drags, DropPosition for specifying where within a target the drop occurs, and DropResult for communicating drop outcomes.

§Design

§Integration with Semantic Events

Drag detection is handled by the gesture recognizer in ftui-core, which emits SemanticEvent::DragStart, DragMove, DragEnd, and DragCancel. The drag manager (bd-1csc.3) listens for these events, identifies the source widget via hit-test, and calls the Draggable methods.

§Invariants

  1. A drag operation is well-formed: exactly one DragStart followed by zero or more DragMove events, ending in either DragEnd or DragCancel.
  2. on_drag_start is called exactly once per drag, before any DragMove.
  3. on_drag_end is called exactly once per drag, with success = true if dropped on a valid target, false otherwise.
  4. drag_type must return a stable string for the lifetime of the drag.

§Failure Modes

FailureCauseFallback
No hit-test match at drag startClick outside any draggableDrag not initiated
Payload decode failureType mismatch at drop targetDrop rejected
Focus loss mid-dragWindow deactivationDragCancel emitted
Escape pressed mid-dragUser cancellationDragCancel emitted (if cancel_on_escape)

Structs§

DragConfig
Configuration for drag gesture detection.
DragPayload
Data carried during a drag operation.
DragPreview
Overlay widget that renders a drag preview at the cursor position.
DragPreviewConfig
Configuration for the drag preview overlay.
DragState
Active drag operation state.

Enums§

DropPosition
Where within a drop target the drop will occur.
DropResult
Outcome of a drop operation.

Traits§

Draggable
Trait for widgets that can be drag sources.
DropTarget
Trait for widgets that can accept drops.