Package: gtk

Function gtk-drag-dest-set

Lambda List

gtk-drag-dest-set (widget flags targets actions)

Arguments

widget -- a gtk-widget object
flags -- a gtk-dest-defaults bitmask with the default drag behavior to use
targets -- a list of target entries indicating the drop types that widget will accept, or nil, later you can access the list with the gtk-drag-dest-target-list and gtk-drag-dest-find-target functions
actions -- a gdk-drag-action bitmask of possible actions for a drop onto the widget

Details

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

The default behaviors listed in the flags argument have an effect similar to installing default handlers "drag-motion", "drag-drop", ... for the drag and drop signals of the widget. They all exist for convenience. When passing the :all value for instance it is sufficient to connect to the "drag-data-received" signal of the widget 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 the "drag-motion" signal. The default behaviors described by the flags argument make some assumptions, that can conflict with your own signal handlers. For instance the :drop value causes invokations of the gdk-drag-status function in the drag context of the "drag-motion" signal, and invokations of the gtk-drag-finish function in the "drag-data-received" handler. Especially the later is dramatic, when your own "drag-motion" handler calls the gtk-drag-data function to inspect the dragged data.

There is no way to set a default action here, you can use the the "drag-motion" callback function for that. Here is an example which selects the action to use depending on whether the Control key is pressed or not:
(defun drag-motion (widget context x y time)
  (declare (ignore x y))
  (let* ((seat (gdk-display-default-seat (gtk-widget-display widget)))
         (device (gdk-seat-pointer seat)))
    (multiple-value-bind (window x y mask)
        (gdk-window-device-position (gtk-widget-window widget) device)
      (if (member :control-mask mask)
          (gdk-drag-status context :copy time)
          (gdk-drag-status context :move time)))))  
 

See also

2021-10-3