Táhni a upusť

Pokud Gtk::TreeView použijete s modelem Gtk::ListStore nebo Gtk::TreeStore, bude již sám o sobě umět jednoduché „táhni a upusť“. Jestliže je to nezbytné, umožňuje také implementaci složitějšího chování při přetahování položek pomocí API Táhni a upusť.

10.6.1. Seřaditelné řádky

Když zavoláte Gtk::TreeView::set_reorderable(), bude možné přesouvat položky v rámci stromového zobrazení. Ukázáno je to v příkladu TreeStore.

However, this does not allow you any control of which items can be dragged, and where they can be dropped. If you need that extra control then you might create a derived Gtk::TreeModel from Gtk::TreeStore or Gtk::ListStore and override the Gtk::TreeDragSource::row_draggable_vfunc() and Gtk::TreeDragDest::row_drop_possible_vfunc() virtual methods. You can examine the Gtk::TreeModel::Paths provided and allow or disallow dragging or dropping by returning true or false.

Ukázané to je v příkladu drag_and_drop.