Contents Up Previous Next

Drag and drop overview

Classes: wxDataObject, wxTextDataObject, wxDropSource, wxDropTarget, wxTextDropTarget, wxFileDropTarget

Note that wxUSE_DRAG_AND_DROP must be defined in setup.h in order to use drag and drop in wxWidgets.

See also: wxDataObject overview and DnD sample

It may be noted that data transfer to and from the clipboard is quite similar to data transfer with drag and drop and the code to implement these two types is almost the same. In particular, both data transfer mechanisms store data in some kind of wxDataObject and identify its format(s) using the wxDataFormat class.

To be a drag source, i.e. to provide the data which may be dragged by the user elsewhere, you should implement the following steps:

To be a drop target, i.e. to receive the data dropped by the user you should follow the instructions below: