Methods

Widgets can be identified as sources or destinations using these Gtk::Widget methods:

void drag_source_set(const Glib::RefPtr<Gdk::ContentFormats>& targets,
      Gdk::ModifierType start_button_mask, Gdk::DragAction actions);
  • targets is a Gdk::ContentFormats object.
  • start_button_mask is an ORed combination of values, which specify which modifier key or mouse button must be pressed to start the drag.
  • actions is an ORed combination of values, which specify which Drag and Drop operations will be possible from this source - for instance, copy, move, or link. The user can choose between the actions by using modifier keys, such as Shift to change from copy to move, and this will be shown by a different cursor.
void drag_dest_set(const Glib::RefPtr<Gdk::ContentFormats>& targets,
    Gtk::DestDefaults flags, Gdk::DragAction actions);
  • flags is an ORed combination of values which indicates how the widget will respond visually to Drag and Drop items.
  • actions indicates the Drag and Drop actions which this destination can receive - see the description above.

There are several methods to add source formats and destination formats. Examples:

  • drag_source_add_text_targets()
  • drag_source_add_image_targets()
  • drag_dest_add_text_targets()
  • drag_dest_add_image_targets()