Drop targets must declare which data types they accept
Aliases: pasteboard types · UTI · MIME type drop · drag flavors
What it is
A target application has to declare in advance which data types it will take: files, plain text, rich text, images, URLs, tables, or a custom industry type. The operating system uses that declaration to match representations the source put on the drag pasteboard. Undeclared, a window the pointer has entered is still not a target. Declared wrongly, a release accepts what it should not, or refuses what it could.
The declaration is a cross-application contract, not the visual hint that “this looks droppable.” The hint is built after the contract already matches.
Why it happens
A source usually offers several representations of the same object: a table can be tab-separated text, HTML, a picture, a native object. The target honors only what it declared. Matching has to happen while the pointer is still moving, so the cursor and highlight can say “accepted here” or “not here.” If the contract is consulted only at release, the entire drag has been lying.
Types have to be specific enough. Declaring only “files” lets the app accept a format it cannot open, and failure is postponed until after the drop. Declaring only a narrow private type means no other app can produce that representation, so the ordinary desktop sources—folders, browser, mail—cannot come in. A good declaration is an ordered list: the richest native form first, then an intermediate that still keeps structure, then a floor such as plain text. Order is part of the contract: the target takes the first match in its preference, the source offers in the same spirit.
Where it stops holding
Some objects have no second representation (an encrypted container, a hardware token); the declaration may be narrow, but a refusal still has to be readable as “wrong type,” not “drag is broken.” Web content dragged into a native app loses a layer of type names between the browser and the OS; the declaration needs to cover those aliases too. A list that is only reordered inside the app has a private contract and need not declare publicly; the moment the object can leave the window, the contract becomes public.
Applying it
- Write an accepted-type list and a priority for every droppable region. On pointer enter, show a “can drop” cursor and highlight only where a match succeeded.
- Offer more than one representation of the same outbound object, so folders, the browser, and mail can come in or go out through at least a floor form.
- Verify by dragging in an image, a plain-text run, an unsupported proprietary file, and a URL. Matching regions highlight on enter; non-matching regions stay “cannot drop” for the whole drag. Open what the target actually stored and confirm it took the preferred representation on the list, not whichever happened to arrive first.