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
- A drag operation is well-formed: exactly one
DragStartfollowed by zero or moreDragMoveevents, ending in eitherDragEndorDragCancel. on_drag_startis called exactly once per drag, before anyDragMove.on_drag_endis called exactly once per drag, withsuccess = trueif dropped on a valid target,falseotherwise.drag_typemust return a stable string for the lifetime of the drag.
§Failure Modes
| Failure | Cause | Fallback |
|---|---|---|
| No hit-test match at drag start | Click outside any draggable | Drag not initiated |
| Payload decode failure | Type mismatch at drop target | Drop rejected |
| Focus loss mid-drag | Window deactivation | DragCancel emitted |
| Escape pressed mid-drag | User cancellation | DragCancel emitted (if cancel_on_escape) |
Structs§
- Drag
Config - Configuration for drag gesture detection.
- Drag
Payload - Data carried during a drag operation.
- Drag
Preview - Overlay widget that renders a drag preview at the cursor position.
- Drag
Preview Config - Configuration for the drag preview overlay.
- Drag
State - Active drag operation state.
Enums§
- Drop
Position - Where within a drop target the drop will occur.
- Drop
Result - Outcome of a drop operation.
Traits§
- Draggable
- Trait for widgets that can be drag sources.
- Drop
Target - Trait for widgets that can accept drops.