.. index:: pair: class; EE::Window::DragAndDrop .. _doxid-class_e_e_1_1_window_1_1_drag_and_drop: class EE::Window::DragAndDrop ============================= .. toctree:: :hidden: Overview ~~~~~~~~ Native cross-application file dragging. :ref:`More...` .. ref-code-block:: cpp :class: doxyrest-overview-code-block #include class DragAndDrop { public: // methods static DragAndDrop :target:`forWindow`(:ref:`Window`& window); static bool :ref:`encodeFileUriList`(const :ref:`DragOffer`& offer, std::string& output, std::string* error = nullptr); :ref:`DragCapabilities` :target:`getCapabilities`() const; :ref:`DragStartResult` :ref:`startDrag`(const :ref:`DragOffer`& offer, :ref:`DragCompletionCallback` completion = {}); void :target:`cancelDrag`(); bool :target:`isDragging`() const; bool :ref:`setDataDropHandler`(std::vector mimeTypes, :ref:`DataDropCallback` callback); bool :ref:`setFileSaveDropHandler`(:ref:`FileSaveDropCallback` callback); }; .. _details-class_e_e_1_1_window_1_1_drag_and_drop: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ Native cross-application file dragging. All methods must run on the window/UI thread. This lightweight facade borrows its :ref:`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). :ref:`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 :ref:`UI ` dragging is independent. Methods ------- .. index:: pair: function; encodeFileUriList .. _doxid-class_e_e_1_1_window_1_1_drag_and_drop_1a4837260c7874093f66402105ff93d58b: .. ref-code-block:: cpp :class: doxyrest-title-code-block static bool encodeFileUriList(const :ref:`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. .. index:: pair: function; startDrag .. _doxid-class_e_e_1_1_window_1_1_drag_and_drop_1a4726f8947be89013401216888a5ee727: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`DragStartResult` startDrag(const :ref:`DragOffer`& offer, :ref:`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. .. index:: pair: function; setDataDropHandler .. _doxid-class_e_e_1_1_window_1_1_drag_and_drop_1a9d684726565233a84fb04ef99767348e: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool setDataDropHandler(std::vector mimeTypes, :ref:`DataDropCallback` callback) Receive drags from other applications that offer one of mimeTypes and no file list (text/uri-list), such as an archive manager's extraction protocol. Drags with a file list keep arriving as FileDropped events. The callback runs on the :ref:`UI ` thread, outside native event hooks, after the source was told the drop succeeded. Replaces this window's previous handler; an empty list removes it. Returns false where unsupported (see dataTarget). .. index:: pair: function; setFileSaveDropHandler .. _doxid-class_e_e_1_1_window_1_1_drag_and_drop_1a07e90b9e2961e7a9cd1a939a163f224b: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool setFileSaveDropHandler(:ref:`FileSaveDropCallback` callback) Receive drags from other applications whose source saves the file where it is dropped (XDS). These take priority over a file list offered with them, which such sources only fill with temporary copies, if at all. The callback runs on the :ref:`UI ` thread, outside native event hooks, when the drag is dropped; the source then saves into the returned folder. Replaces this window's previous handler; an empty callback removes it. Returns false where unsupported (see dataTarget).