gtkDragDestSet: gtkDragDestSet

Description Usage Arguments Details Author(s)

View source: R/gtkFuncs.R

Description

Sets a widget as a potential drop destination, and adds default behaviors.

Usage

1
gtkDragDestSet(object, flags, targets, actions)

Arguments

object

a GtkWidget

flags

which types of default drag behavior to use

targets

a pointer to a list of GtkTargetEntrys indicating the drop types that this widget will accept, or NULL. Later you can access the list with gtkDragDestGetTargetList and gtkDragDestFindTarget. [ allow-none ][ array length=n_targets]

actions

a bitmask of possible actions for a drop onto this widget.

Details

The default behaviors listed in flags have an effect similar to installing default handlers for the widget's drag-and-drop signals ("drag-motion", "drag-drop", ...). They all exist for convenience. When passing GTK_DEST_DEFAULT_ALL for instance it is sufficient to connect to the widget's "drag-data-received" signal to get primitive, but consistent drag-and-drop support.

Things become more complicated when you try to preview the dragged data, as described in the documentation for "drag-motion". The default behaviors described by flags make some assumptions, that can conflict with your own signal handlers. For instance GTK_DEST_DEFAULT_DROP causes invokations of gdkDragStatus in the context of "drag-motion", and invokations of gtkDragFinish in "drag-data-received". Especially the later is dramatic, when your own "drag-motion" handler calls gtkDragGetData to inspect the dragged data.

There's no way to set a default action here, you can use the "drag-motion" callback for that. Here's an example which selects the action to use depending on whether the control key is pressed or not:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
static void
drag_motion (GtkWidget *widget,
             GdkDragContext *context,
             gint x,
             gint y,
             guint time)
{
  GdkModifierType mask;

  gdk_window_get_pointer (gtk_widget_get_window (widget),
                          NULL, NULL, &mask);
  if (mask & GDK_CONTROL_MASK)
    gdk_drag_status (context, GDK_ACTION_COPY, time);
  else
    gdk_drag_status (context, GDK_ACTION_MOVE, time);
}

Author(s)

Derived by RGtkGen from GTK+ documentation


RGtk2 documentation built on Oct. 14, 2021, 5:08 p.m.

Related to gtkDragDestSet in RGtk2...