Package: gtk
Function gtk-drag-dest-set
Lambda Listgtk-drag-dest-set (widget flags targets actions) ArgumentsDetails
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