class EE::Window::DragAndDrop¶
Overview¶
Native cross-application file dragging. More…
#include <draganddrop.hpp> class DragAndDrop { public: // methods static DragAndDrop forWindow(Window& window); static bool encodeFileUriList(const DragOffer& offer, std::string& output, std::string* error = nullptr); DragCapabilities getCapabilities() const; DragStartResult startDrag(const DragOffer& offer, DragCompletionCallback completion = {}); void cancelDrag(); bool isDragging() const; };
Detailed Documentation¶
Native cross-application file dragging. All methods must run on the window/UI thread. This lightweight facade borrows its Window and must not outlive it. A started session owns its serialized payload and completion callback. Rejected starts never invoke completion. Completions run once, outside native event hooks, when input is updated; they may start another drag. Cancellation/closing a source window also completes the session. Callbacks must not borrow objects that may be destroyed before completion (use weak ownership when appropriate). Engine teardown cancels and releases pending sessions without invoking their callbacks. Initially only Copy is supported. Dropped means the native transfer finished, not that a browser uploaded or a file manager copied a file. Existing internal UI dragging is independent.
Methods¶
static bool encodeFileUriList(const DragOffer& offer, std::string& output, std::string* error = nullptr)
Serialize an offer as text/uri-list (CRLF). Rejects empty, relative, invalid UTF-8 and NUL paths. Preserves order and duplicate entries. On failure output is empty.
DragStartResult startDrag(const DragOffer& offer, DragCompletionCallback completion = {})
Call after a movement threshold, while the initiating left mouse button is still down. Preview images must be RGB/RGBA, at most 2048 pixels per side and 1,048,576 pixels total. The offer is read synchronously; the session retains only its own native representation.