Skip to main content

Crate tauri_plugin_dragout

Crate tauri_plugin_dragout 

Source
Expand description

Native drag-out for Tauri 2.

A webview cannot start an OS-level file drag on its own: an HTML dragstart in WKWebView only carries text, URLs or in-page data, so users cannot drag a document out of a Tauri app onto Finder, the Desktop, Mail or Slack. This plugin starts a real NSDraggingSession from the window under the mouse and lets you drag:

  • existing files (DragItem::File): the target receives the file itself;
  • copies of files (DragItem::Copy): copied only when dropped, optionally under another name;
  • generated bytes (DragItem::Data): written to the drop location on drop;
  • lazy promises (DragItem::promise, Rust only): your closure writes the file when (and only if) the user actually drops it, e.g. export, decrypt or download on demand.

Supported on macOS. On other platforms the plugin compiles, is_supported returns false and start_drag returns Error::Unsupported.

tauri::Builder::default()
    .plugin(tauri_plugin_dragout::init())

Structs§

Builder
Plugin builder.
DragOptions
Options for a drag session.
DragSession
Handle of a started drag; matches the session field of the plugin events.

Enums§

DragItem
One thing to drag.
Error
Errors returned by start_drag.

Constants§

EVENT_DROPPED
Event emitted when a promised item has been written at its drop location.
EVENT_ENDED
Event emitted when a drag session ends (dropped or cancelled).
EVENT_ERROR
Event emitted when writing a promised item failed.

Functions§

init
Plugin with default settings.
is_supported
Whether native drag-out works on this platform.
start_drag
Start a native drag from window with items.

Type Aliases§

PromiseWriter
Writer used by DragItem::Promise: receives the full destination path.