DropTargetAsync

class DropTargetAsync(**properties: Any)

Superclasses: EventController, Object

Constructors:

DropTargetAsync(**properties)
new(formats:Gdk.ContentFormats=None, actions:Gdk.DragAction) -> Gtk.DropTargetAsync

Constructors

class DropTargetAsync
classmethod new(formats: ContentFormats | None, actions: DragAction) DropTargetAsync

Creates a new GtkDropTargetAsync object.

Parameters:
  • formats – the supported data formats

  • actions – the supported actions

Methods

class DropTargetAsync
get_actions() DragAction

Gets the actions that this drop target supports.

get_formats() ContentFormats | None

Gets the data formats that this drop target accepts.

If the result is None, all formats are expected to be supported.

reject_drop(drop: 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.

Parameters:

drop – the GdkDrop of an ongoing drag operation

set_actions(actions: DragAction) None

Sets the actions that this drop target supports.

Parameters:

actions – the supported actions

set_formats(formats: ContentFormats | None = None) None

Sets the data formats that this drop target will accept.

Parameters:

formats – the supported data formats or None for any format

Properties

class DropTargetAsync
props.actions: DragAction

The GdkDragActions that this drop target supports.

props.formats: ContentFormats

The GdkContentFormats that determines the supported data formats.

Signals

class DropTargetAsync.signals
accept(drop: Drop) bool

Emitted on the drop site when a drop operation is about to begin.

If the drop is not accepted, False will be returned and the drop target will ignore the drop. If True is returned, the drop is accepted for now but may be rejected later via a call to reject_drop or ultimately by returning False from a 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 True and proceed as is drop was accepted and if it decides to reject the drop later, it should call reject_drop.

Parameters:

drop – the GdkDrop

drag_enter(drop: Drop, x: float, y: float) DragAction

Emitted on the drop site when the pointer enters the widget.

It can be used to set up custom highlighting.

Parameters:
  • drop – the GdkDrop

  • x – the x coordinate of the current pointer position

  • y – the y coordinate of the current pointer position

drag_leave(drop: 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.

Parameters:

drop – the GdkDrop

drag_motion(drop: Drop, x: float, y: float) DragAction

Emitted while the pointer is moving over the drop target.

Parameters:
  • drop – the GdkDrop

  • x – the x coordinate of the current pointer position

  • y – the y coordinate of the current pointer position

drop(drop: 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 False and no further processing is necessary.

Otherwise, the handler returns True. In this case, this handler will accept the drop. The handler must ensure that finish is called to let the source know that the drop is done. The call to finish must only be done when all data has been received.

To receive the data, use one of the read functions provided by Drop such as read_async or read_value_async.

Parameters:
  • drop – the GdkDrop

  • x – the x coordinate of the current pointer position

  • y – the y coordinate of the current pointer position