[Previous] [Contents] [Index] [Next]

PtInitDnd()

Initiate a drag-and-drop operation

Synopsis:

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

Library:

ph

Description:

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.

The widget argument 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.

The event argument points to a PhEvent_t structure that describes the event that was used to precipitate the operation.

The cursors argument, 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.

The flags argument is a combination of the following bits:

Pt_DND_SILENT
Don't notify the initiator of drag-and-drop progress (valid only if no requestable data types were added to the PtTransportCtrl_t structure).
Pt_DND_LOCAL
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.

Returns:

0
Success.
-1
An error occurred.

Examples:

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, NULL, NULL,
               Pt_DND_LOCAL | Pt_DND_SILENT );
    return Pt_CONTINUE;
}

Classification:

Photon

Safety:
Interrupt handler No
Signal handler No
Thread No

See also:

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

Drag and Drop chapter of the Photon Programmer's Guide


[Previous] [Contents] [Index] [Next]