:right-sidebar: True DropTargetAsync =================================================================== .. currentmodule:: gi.repository.Gtk .. class:: DropTargetAsync(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.Gtk.EventController`, :class:`~gi.repository.GObject.Object` :Constructors: :: DropTargetAsync(**properties) new(formats:Gdk.ContentFormats=None, actions:Gdk.DragAction) -> Gtk.DropTargetAsync Constructors ------------ .. rst-class:: interim-class .. class:: DropTargetAsync :no-index: .. classmethod:: new(formats: ~gi.repository.Gdk.ContentFormats | None, actions: ~gi.repository.Gdk.DragAction) -> ~gi.repository.Gtk.DropTargetAsync Creates a new ``GtkDropTargetAsync`` object. :param formats: the supported data formats :param actions: the supported actions Methods ------- .. rst-class:: interim-class .. class:: DropTargetAsync :no-index: .. method:: get_actions() -> ~gi.repository.Gdk.DragAction Gets the actions that this drop target supports. .. method:: get_formats() -> ~gi.repository.Gdk.ContentFormats | None Gets the data formats that this drop target accepts. If the result is :const:`None`, all formats are expected to be supported. .. method:: reject_drop(drop: ~gi.repository.Gdk.Drop) -> None Sets the ``drop`` as not accepted on this drag site. This function should be used when delaying the decision on whether to accept a drag or not until after reading the data. :param drop: the ``GdkDrop`` of an ongoing drag operation .. method:: set_actions(actions: ~gi.repository.Gdk.DragAction) -> None Sets the actions that this drop target supports. :param actions: the supported actions .. method:: set_formats(formats: ~gi.repository.Gdk.ContentFormats | None = None) -> None Sets the data formats that this drop target will accept. :param formats: the supported data formats or :const:`None` for any format Properties ---------- .. rst-class:: interim-class .. class:: DropTargetAsync :no-index: .. attribute:: props.actions :type: ~gi.repository.Gdk.DragAction The ``GdkDragActions`` that this drop target supports. .. attribute:: props.formats :type: ~gi.repository.Gdk.ContentFormats The ``GdkContentFormats`` that determines the supported data formats. Signals ------- .. rst-class:: interim-class .. class:: DropTargetAsync.signals :no-index: .. method:: accept(drop: ~gi.repository.Gdk.Drop) -> bool Emitted on the drop site when a drop operation is about to begin. If the drop is not accepted, :const:`False` will be returned and the drop target will ignore the drop. If :const:`True` is returned, the drop is accepted for now but may be rejected later via a call to :obj:`~gi.repository.Gtk.DropTargetAsync.reject_drop` or ultimately by returning :const:`False` from a :obj:`~gi.repository.Gtk.DropTargetAsync.signals.drop` handler. The default handler for this signal decides whether to accept the drop based on the formats provided by the ``drop``. If the decision whether the drop will be accepted or rejected needs further processing, such as inspecting the data, this function should return :const:`True` and proceed as is ``drop`` was accepted and if it decides to reject the drop later, it should call :obj:`~gi.repository.Gtk.DropTargetAsync.reject_drop`. :param drop: the ``GdkDrop`` .. method:: drag_enter(drop: ~gi.repository.Gdk.Drop, x: float, y: float) -> ~gi.repository.Gdk.DragAction Emitted on the drop site when the pointer enters the widget. It can be used to set up custom highlighting. :param drop: the ``GdkDrop`` :param x: the x coordinate of the current pointer position :param y: the y coordinate of the current pointer position .. method:: drag_leave(drop: ~gi.repository.Gdk.Drop) -> None Emitted on the drop site when the pointer leaves the widget. Its main purpose it to undo things done in ``GtkDropTargetAsync``::drag-enter. :param drop: the ``GdkDrop`` .. method:: drag_motion(drop: ~gi.repository.Gdk.Drop, x: float, y: float) -> ~gi.repository.Gdk.DragAction Emitted while the pointer is moving over the drop target. :param drop: the ``GdkDrop`` :param x: the x coordinate of the current pointer position :param y: the y coordinate of the current pointer position .. method:: drop(drop: ~gi.repository.Gdk.Drop, x: float, y: float) -> bool Emitted on the drop site when the user drops the data onto the widget. The signal handler must determine whether the pointer position is in a drop zone or not. If it is not in a drop zone, it returns :const:`False` and no further processing is necessary. Otherwise, the handler returns :const:`True`. In this case, this handler will accept the drop. The handler must ensure that :obj:`~gi.repository.Gdk.Drop.finish` is called to let the source know that the drop is done. The call to :obj:`~gi.repository.Gdk.Drop.finish` must only be done when all data has been received. To receive the data, use one of the read functions provided by :obj:`~gi.repository.Gdk.Drop` such as :obj:`~gi.repository.Gdk.Drop.read_async` or :obj:`~gi.repository.Gdk.Drop.read_value_async`. :param drop: the ``GdkDrop`` :param x: the x coordinate of the current pointer position :param y: the y coordinate of the current pointer position