方法

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

void drag_source_set(const ArrayHandle_TargetEntry& targets,
      GdkModifierType start_button_mask, GdkDragAction actions);
  • targets is a container of Gtk::TargetEntry (std::list<Gtk::TargetEntry> or std::vector<Gtk::TargetEntry>, for instance) elements.
  • 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 specified 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 ArrayHandle_TargetEntry& targets,
    GtkDestDefaults flags, GdkDragAction 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.