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.
- Drag
Options - Options for a drag session.
- Drag
Session - Handle of a started drag; matches the
sessionfield of the plugin events.
Enums§
- Drag
Item - 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
windowwithitems.
Type Aliases§
- Promise
Writer - Writer used by
DragItem::Promise: receives the full destination path.