Upstream: crates/rune/README.md § Dragging out to other apps (drag_out) at 65f8eb43f710, MIT © Anomaly. Bundled by build-rune-apps; links point at this snapshot or at GitHub at that rev.

Dragging out to other apps (drag_out)

.drag_out(..) makes an element a system drag source: drag it into Finder, Mail or System Settings and the other app receives files, PNG data or text.

el().child(text("Example"))
    .drag_out(|s: &App| Some(DragItem::new().file("/Applications/Example.app")))
    .on_drag_end(|s: &mut App, outcome, _tx| s.last_drop = Some(outcome))

The closure runs once the pointer travels DRAG_THRESHOLD (4 pt; 8 pt on Linux) from the press, so it can read current state; None cancels this drag and the press stays a press. A press released before the threshold still runs on_press; a drag-out element never runs on_drag. Once the system drag starts, Rune drops the pointer capture and hover, so nothing stays pressed. Files are offered as copies (DragItem::allow_move also offers a move), an app bundle can be dropped into System Settings' privacy lists, and the picture under the pointer is a snapshot of the element unless DragItem::image sets one. on_drag_end receives DragOutcome::Copied, Moved, Linked or Cancelled. The app's own windows take no drop from its drags unless DragItem::within_app offers it to them: their on_drop_files targets then receive the files as they would from Finder (an image dragged from a list into a composer).

macOS only for now. Elsewhere drag_out is ignored and the element keeps its press and on_drag behaviour. Headless runs record drag-out <path> in --trace and mark the node dragOut in --tree. examples/drag-out drags a file, an app and some text.