:right-sidebar: True Drag =================================================================== .. currentmodule:: gi.repository.Gdk .. class:: Drag(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.Object` :Constructors: :: Drag(**properties) Methods ------- .. rst-class:: interim-class .. class:: Drag :no-index: .. method:: begin(surface: ~gi.repository.Gdk.Surface, device: ~gi.repository.Gdk.Device, content: ~gi.repository.Gdk.ContentProvider, actions: ~gi.repository.Gdk.DragAction, dx: float, dy: float) -> ~gi.repository.Gdk.Drag | None Starts a drag and creates a new drag context for it. This function is called by the drag source. After this call, you probably want to set up the drag icon using the surface returned by :obj:`~gi.repository.Gdk.Drag.get_drag_surface`. This function returns a reference to the :obj:`~gi.repository.Gdk.Drag` object, but GTK keeps its own reference as well, as long as the DND operation is going on. Note: if ``actions`` include :const:`~gi.repository.Gdk.DragAction.MOVE`, you need to listen for the :obj:`~gi.repository.Gdk.Drag.signals.dnd_finished` signal and delete the data at the source if :obj:`~gi.repository.Gdk.Drag.get_selected_action` returns :const:`~gi.repository.Gdk.DragAction.MOVE`. :param surface: the source surface for this drag :param device: the device that controls this drag :param content: the offered content :param actions: the actions supported by this drag :param dx: the x offset to ``device``'s position where the drag nominally started :param dy: the y offset to ``device``'s position where the drag nominally started .. method:: drop_done(success: bool) -> None Informs GDK that the drop ended. Passing :const:`False` for ``success`` may trigger a drag cancellation animation. This function is called by the drag source, and should be the last call before dropping the reference to the ``drag``. The ``GdkDrag`` will only take the first :obj:`~gi.repository.Gdk.Drag.drop_done` call as effective, if this function is called multiple times, all subsequent calls will be ignored. :param success: whether the drag was ultimatively successful .. method:: get_actions() -> ~gi.repository.Gdk.DragAction Determines the bitmask of possible actions proposed by the source. .. method:: get_content() -> ~gi.repository.Gdk.ContentProvider Returns the ``GdkContentProvider`` associated to the ``GdkDrag`` object. .. method:: get_device() -> ~gi.repository.Gdk.Device Returns the ``GdkDevice`` associated to the ``GdkDrag`` object. .. method:: get_display() -> ~gi.repository.Gdk.Display Gets the ``GdkDisplay`` that the drag object was created for. .. method:: get_drag_surface() -> ~gi.repository.Gdk.Surface | None Returns the surface on which the drag icon should be rendered during the drag operation. Note that the surface may not be available until the drag operation has begun. GDK will move the surface in accordance with the ongoing drag operation. The surface is owned by ``drag`` and will be destroyed when the drag operation is over. .. method:: get_formats() -> ~gi.repository.Gdk.ContentFormats Retrieves the formats supported by this ``GdkDrag`` object. .. method:: get_selected_action() -> ~gi.repository.Gdk.DragAction Determines the action chosen by the drag destination. .. method:: get_surface() -> ~gi.repository.Gdk.Surface Returns the ``GdkSurface`` where the drag originates. .. method:: set_hotspot(hot_x: int, hot_y: int) -> None Sets the position of the drag surface that will be kept under the cursor hotspot. Initially, the hotspot is at the top left corner of the drag surface. :param hot_x: x coordinate of the drag surface hotspot :param hot_y: y coordinate of the drag surface hotspot Properties ---------- .. rst-class:: interim-class .. class:: Drag :no-index: .. attribute:: props.actions :type: ~gi.repository.Gdk.DragAction The possible actions of this drag. .. attribute:: props.content :type: ~gi.repository.Gdk.ContentProvider The ``GdkContentProvider``. .. attribute:: props.device :type: ~gi.repository.Gdk.Device The ``GdkDevice`` that is performing the drag. .. attribute:: props.display :type: ~gi.repository.Gdk.Display The ``GdkDisplay`` that the drag belongs to. .. attribute:: props.formats :type: ~gi.repository.Gdk.ContentFormats The possible formats that the drag can provide its data in. .. attribute:: props.selected_action :type: ~gi.repository.Gdk.DragAction The currently selected action of the drag. .. attribute:: props.surface :type: ~gi.repository.Gdk.Surface The surface where the drag originates. Signals ------- .. rst-class:: interim-class .. class:: Drag.signals :no-index: .. method:: cancel(reason: ~gi.repository.Gdk.DragCancelReason) -> None Emitted when the drag operation is cancelled. :param reason: The reason the drag was cancelled .. method:: dnd_finished() -> None Emitted when the destination side has finished reading all data. The drag object can now free all miscellaneous data. .. method:: drop_performed() -> None Emitted when the drop operation is performed on an accepting client.