DropTargetAsync


Object Hierarchy:

Object hierarchy for DropTargetAsync

Description:

[ CCode ( type_id = "gtk_drop_target_async_get_type ()" ) ]
public class DropTargetAsync : EventController

GtkDropTargetAsync is an auxiliary object that can be used to receive Drag-and-Drop operations.

It is the more complete but also more complex method of handling drop operations compared to DropTarget and you should only use it if DropTarget doesn't provide all the features you need.

To use a DropTargetAsync to receive drops on a widget, you create a DropTargetAsync object, configure which data formats and actions you support, connect to its signals, and then attach it to the widget with add_controller.

During a drag operation, the first signal that a GtkDropTargetAsync emits is accept, which is meant to determine whether the target is a possible drop site for the ongoing drop. The default handler for the accept signal accepts the drop if it finds a compatible data format and an action that is supported on both sides.

If it is, and the widget becomes a target, you will receive a drag_enter signal, followed by drag_motion signals as the pointer moves, optionally a drop signal when a drop happens, and finally a drag_leave signal when the pointer moves off the widget.

The drag_enter and drag_motion handler return a DragAction to update the status of the ongoing operation. The drop handler should decide if it ultimately accepts the drop and if it does, it should initiate the data transfer and finish the operation by calling finish.

Between the drag_enter and drag_leave signals the widget is a current drop target, and will receive the gtk_state_flag_drop_active state, which can be used by themes to style the widget as a drop target.


Namespace: Gtk
Package: gtk4

Content:

Properties:

Creation methods:

Methods:

Signals:

Inherited Members: