Drag and drop

On this page 7

Drag and drop is a direct manipulation technique in which a user presses on an object, moves the pointer while holding it, and releases it over a target to move, copy, link or apply that object. In Desktop environments it is one of the core interactions of the desktop metaphor, used to move files between folders, rearrange windows and icons, and pass data from one application to another.

Behind the simple gesture sits a negotiation protocol between the source application, the target application and the display server, which decides what data is offered, in which formats, and which operation finally takes place.

How a drag and drop operation works

A drag and drop operation is a short-lived data transfer with a defined life cycle. The source declares what it can provide, the targets under the pointer declare what they accept, and the transfer happens only when the user releases the button over a willing target.

The table below summarizes the phases that most desktop platforms share.

PhaseWhat the system doesTypical feedback
Drag startDetects a press plus movement beyond a small thresholdDrag image appears under the pointer
Data offerSource publishes data formats and allowed actionsNone visible
Drag overEach target under the pointer accepts or rejects the offerCursor changes, target highlights
DropTarget requests data in its preferred formatItem appears at the new place
CompletionSource learns the result, for example deletes after a moveOriginal disappears or stays
Phases of a drag and drop operation

The drag threshold, usually a few pixels of movement, prevents an ordinary click from starting a drag by accident. Data is often transferred lazily: the source does not render a large file or image until a target actually requests it, which keeps dragging fast even with heavy content.

The same gesture can produce different results, and the effective action depends on the source, the target and any modifier keys. File managers follow conventions that experienced users rely on, although the exact keys differ between platforms.

ActionResultCommon default or modifier
MoveObject leaves the source and appears at the targetDefault within the same volume
CopyA duplicate appears at the targetDefault across volumes; Ctrl or Option key
LinkA shortcut, alias or symbolic link is createdCtrl+Shift, Alt or Command+Option
AskA menu lets the user pick the action after the dropRight-button or middle-button drag
Drop actions and how they are usually chosen

The rule that a drag moves within a disk but copies across disks surprises many users, because the same gesture has different consequences. Good interfaces show the pending action with a cursor badge, such as a plus sign for copy or an arrow for a link, before the user releases the button.

Drag and drop protocols on major platforms

Each windowing system implements drag and drop through its own protocol and data model, and GUI toolkits hide most of these differences from application developers. Data is described with format identifiers, such as MIME types, so that a target can choose plain text, rich text, an image or a file list.

PlatformMechanismData description
WindowsOLE drag and drop with data objectsClipboard formats
macOSDragging sessions in AppKitUniform type identifiers
X11 desktopsXDND protocol between clientsMIME types
Wayland desktopsData device protocol through the compositorMIME types
Web browsersHTML drag and drop eventsMIME types in a data transfer object
Drag and drop mechanisms by platform

Drag and drop is closely related to the clipboard: both offer data in several formats and let the receiver choose. The difference is that the clipboard keeps data until it is replaced, whereas a drag offer exists only during the gesture. On Wayland, the compositor mediates the transfer, so an application cannot read drag data that the user has not actually dropped onto it.

Design guidelines for usable drag and drop

Drag and drop is efficient for spatial tasks but hard to discover and physically demanding, so it should rarely be the only way to perform an action. Interface guidelines on all major platforms recommend equivalent menu or keyboard commands for every drag operation.

  • Show valid targets clearly by highlighting them while the pointer is over them.
  • Indicate the pending action with the cursor so that move and copy are not confused.
  • Support cancellation with the Escape key or by dropping back on the origin.
  • Offer undo for moves and deletions, because a misplaced drop is a common error.
  • Scroll automatically when the pointer reaches the edge of a long list or window.

Accessibility deserves special attention. Users of keyboards, switch devices or screen readers cannot easily perform a precise drag, and requirements such as WCAG 2.2 success criterion 2.5.7 ask for a single-pointer alternative to dragging movements.

Limitations and common problems

Most problems with drag and drop come from mismatched expectations between applications or from security boundaries. The table below lists frequent symptoms and their usual causes.

SymptomLikely causeRemedy
Drop is rejected with a forbidden cursorTarget does not accept any offered formatExport in a common format first
Files cannot be dropped into an elevated windowPrivilege separation blocks the transferRun both applications at the same level
Sandboxed app receives no fileSandbox grants access only through a portalUse the platform file transfer portal
File moved instead of copiedSame-volume default actionHold the copy modifier or undo
Drag fails on touch screensLong press is interpreted as a context menuUse the touch drag gesture of the platform
Typical drag and drop problems

Accidental drops remain the classic risk: a file released one folder too early can seem lost. Undo support and visible feedback solve most of these cases, which is why mature file managers treat every drop as a reversible operation.

In plain words

Drag and drop is the computer version of picking something up and putting it somewhere else. You press on an item, such as a photo or a document, keep holding, move it to where you want it, and let go.

It works between folders, inside programs and even between different programs. The computer checks whether the place under your pointer can accept what you are carrying, and the pointer often changes shape to show whether the item will be moved or copied. The main point is that it feels natural, but it should always be easy to undo.

A real-world example

A marketing assistant prepares a product brochure on a Linux workstation running a Wayland desktop. She opens the file manager next to a layout application and drags twelve product photos from a network folder straight onto the page layout.

Because the photos come from a different volume, the file manager offers a copy by default, and the layout application accepts the drop as a list of file URIs. The compositor passes the data only to the window where she releases the button. When she later drags one image onto the trash icon by mistake, she presses Ctrl+Z in the file manager and the image returns to its folder.

The task takes about two minutes instead of importing each photo through a file dialog, and the undo function prevents data loss from the misplaced drop.