Widget.connectDragMotion

gulong connectDragMotion(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == bool) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gdk.drag_context.DragContext))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] == int))) && (Parameters!T.length < 3 || (ParameterStorageClassTuple!T[2] == ParameterStorageClass.none && is(Parameters!T[2] == int))) && (Parameters!T.length < 4 || (ParameterStorageClassTuple!T[3] == ParameterStorageClass.none && is(Parameters!T[3] == uint))) && (Parameters!T.length < 5 || (ParameterStorageClassTuple!T[4] == ParameterStorageClass.none && is(Parameters!T[4] : gtk.widget.Widget))) && Parameters!T.length < 6)

Connect to DragMotion signal.

The ::drag-motion signal is emitted on the drop site when the user moves the cursor over the widget during a drag. The signal handler must determine whether the cursor position is in a drop zone or not. If it is not in a drop zone, it returns false and no further processing is necessary. Otherwise, the handler returns true. In this case, the handler is responsible for providing the necessary information for displaying feedback to the user, by calling [gdk.global.dragStatus].

If the decision whether the drop will be accepted or rejected can't be made based solely on the cursor position and the type of the data, the handler may inspect the dragged data by calling [gtk.widget.Widget.dragGetData] and defer the [gdk.global.dragStatus] call to the #GtkWidget::drag-data-received handler. Note that you must pass #GTK_DEST_DEFAULT_DROP, #GTK_DEST_DEFAULT_MOTION or #GTK_DEST_DEFAULT_ALL to [gtk.widget.Widget.dragDestSet] when using the drag-motion signal that way.

Also note that there is no drag-enter signal. The drag receiver has to keep track of whether he has received any drag-motion signals since the last #GtkWidget::drag-leave and if not, treat the drag-motion signal as an "enter" signal. Upon an "enter", the handler will typically highlight the drop site with [gtk.widget.Widget.dragHighlight].

static void
 drag_motion (GtkWidget      *widget,
              GdkDragContext *context,
              gint            x,
              gint            y,
              guint           time)
 {
   GdkAtom target;

   PrivateData *private_data = GET_PRIVATE_DATA (widget);

   if (!private_data->drag_highlight)
    {
      private_data->drag_highlight = 1;
      gtk_drag_highlight (widget);
    }

   target = gtk_drag_dest_find_target (widget, context, NULL);
   if (target == GDK_NONE)
     gdk_drag_status (context, 0, time);
   else
    {
      private_data->pending_status
         = gdk_drag_context_get_suggested_action (context);
      gtk_drag_get_data (widget, context, target, time);
    }

   return TRUE;
 }

 static void
 drag_data_received (GtkWidget        *widget,
                     GdkDragContext   *context,
                     gint              x,
                     gint              y,
                     GtkSelectionData *selection_data,
                     guint             info,
                     guint             time)
 {
   PrivateData *private_data = GET_PRIVATE_DATA (widget);

   if (private_data->suggested_action)
    {
      private_data->suggested_action = 0;

      // We are getting this data due to a request in drag_motion,
      // rather than due to a request in drag_drop, so we are just
      // supposed to call gdk_drag_status(), not actually paste in
      // the data.

      str = gtk_selection_data_get_text (selection_data);
      if (!data_is_acceptable (str))
        gdk_drag_status (context, 0, time);
      else
        gdk_drag_status (context,
                         private_data->suggested_action,
                         time);
    }
   else
    {
      // accept the drop
    }
 }

Parameters

callbacksignal callback delegate or function to connect bool callback(gdk.drag_context.DragContext context, int x, int y, uint time, gtk.widget.Widget widget) context the drag context (optional) x the x coordinate of the current cursor position (optional) y the y coordinate of the current cursor position (optional) time the timestamp of the motion event (optional) widget the instance the signal is connected to (optional) Returns whether the cursor position is in a drop zone
afterYes.After to execute callback after default handler, No.After to execute before (default)

Returns

Signal ID