Defined in header <nana/gui/dragdrop.hpp>
class simple_dragdrop;

The class simple_dragdrop is used for easily implementing data exchange using drag-and-drop feature in current process.

The class simple_dragdrop informs program when drag-and-drop operation is done. It doesn't hold the data which is exchanged during drag-and-drop operation.

When a simple_dragdrop object is constructed, the associated window is enabled for drag-and-drop operation. When the object is destructed, the associated window is disabled for drag-and-drop operation.

Member functions


The class simple_dragdrop informs program using a callback when the drag-and-drop operation is done.
#include <nana/gui.hpp>
#include <nana/gui/widgets/listbox.hpp>
#include <nana/gui/dragdrop.hpp>

int main()
    using namespace nana;

    form fm;
    listbox list1{ fm };
    listbox list2{ fm };


    //Add items
        for (int i = 0; i < 100; ++i)
  { "item " + std::to_string(i) });

    fm["list1"] << list1;
    fm["list2"] << list2;

    //Enables drag&drop from list1 to list2
    simple_dragdrop smpl_dnd{ list1 };

	//Let's set a condition checker which returns true if the mouse is hovered
	//on an item of list1.
	//When the left mouse button is pressed and the condition checker returns true,
	//the drag-and-drop will start.
        return !list1.hovered(false).empty();

    //Sets the drop target and specifies a function to transfer
    //data from list1 to list2.
	//When the mouse button is dragged from list1 to list2 and is released on list2, the
	//simple_dragdrop will call the callback to inform the program that drag-and-drop
	//operation is done. Then the program should transfer the data for the operation.
    smpl_dnd.make_drop(list2, [&]{
        auto selections = list1.selected();

		//Transfers the data
            for (auto & s : selections)
      { });



See also