Caution: This version of this document is no longer maintained. For the latest documentation, see


Initiate a drag-and-drop operation


int PtInitDnd( PtTransportCtrl_t *ctrl,
               PtWidget_t *widget,
               PhEvent_t *event,
               PhDndCursors_t *cursors,
               int unsigned flags );


A pointer to a PtTransportCtrl_t structure which contains the data that the function uses to initiate a drag-and-drop operation.
A pointer to a PtWidget_t sturcture which specifies the widget on whose behalf the drag-and-drop operation is being started. It's this widget that receives all drag-and-drop progress-notification events and callbacks.
A pointer to a PhEvent_t structure that describes the event that was used to precipitate the operation. This may be a pointer event (Ph_EV_PTR_MOTION_*) or drag event (Ph_EV_DRAG). If the event isn't of one of these types, the function will fail.

Note: If the drag event's subtype isn't Ph_EV_DRAG_COMPLETE, you'll have to cancel the drag first, using PhCancelDrag().

A pointer to a PhDndCursors_t structure which, if provided, is used instead of the default drag-and-drop cursors (accept, reject, unknown... app not responding) if the destination doesn't override them.

PhDndCursors_t contains three members, all pointers to PhCursorDescription_t, which describe the cursor's appearance when performing a drag-and-drop operation:

typedef struct Ph_ev_dndrop_cursors {
    const PhCursorDescription_t *active, *inactive, *unknown;
} PhDndCursors_t;
A combination of the following bits:
Don't notify the initiator of drag-and-drop progress (valid only if no requestable data types were added to the PtTransportCtrl_t structure).
Restrict the drop so that it can occur only within the context of the application that initiated the drag-and-drop. That is to say that the user can't drop the data on any other application. This is very useful for allowing the dragging and dropping of private data or pointer references that are meaningful only within a single application's context.




This function initiates a drag-and-drop operation with the data previously added to the PtTransportCtrl_t structure pointed to by ctrl. Before calling PtInitDnd(), your application must create this structure by calling PtCreateTransportCtrl() and populate it via calls to PtTransportType() and PtTransportRequestable().

The structure pointed to by ctrl is automatically released at the end of the drag-and-drop operation.


An error occurred.


int cb_outbound (PtWidget_t *widget, void *data,
                 PtCallbackInfo_t *cbinfo);
    PtTransportCtrl_t *tctrl = PtCreateTransportCtrl();
    PtTransportType( tctrl, "text", "simple sentence",
                     0, Ph_TRANSPORT_INLINE, "string",
                     "This is my inlined data.", 0, 0 );
    PtInitDnd( tctrl, widget, cbinfo->event, NULL,
               Pt_DND_LOCAL | Pt_DND_SILENT );
    return Pt_CONTINUE;



Interrupt handler No
Signal handler No
Thread No

See also:

PhCursorDescription_t, PhCancelDrag(), PhEvent_t, PtCancelDnd(), PtCreateTransportCtrl(), PtDndFetch_t, PtDndSelect(), PtTransportCtrl_t, PtTransportType()

Drag and Drop chapter of the Photon Programmer's Guide