DropTargetAsync

gtk.drop_target_async.DropTargetAsync is an event controller to receive Drag-and-Drop operations, asynchronously.

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

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

During a drag operation, the first signal that a gtk.drop_target_async.DropTargetAsync emits is gtk.drop_target_async.DropTargetAsync.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 signal@Gtk.DropTargetAsync::drag-enter signal, followed by signal@Gtk.DropTargetAsync::drag-motion signals as the pointer moves, optionally a gtk.drop_target_async.DropTargetAsync.drop signal when a drop happens, and finally a signal@Gtk.DropTargetAsync::drag-leave signal when the pointer moves off the widget.

The ::drag-enter and ::drag-motion handler return a gdk.types.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 gdk.drop.Drop.finish.

Between the ::drag-enter and ::drag-leave signals the widget is a current drop target, and will receive the gtk.types.StateFlags.DropActive state, which can be used by themes to style the widget as a drop target.

Constructors

this
this(gdk.content_formats.ContentFormats formats, gdk.types.DragAction actions)

Creates a new gtk.drop_target_async.DropTargetAsync object.

Members

Functions

connectAccept
ulong connectAccept(T callback, Flag!"After" after)

Connect to Accept signal.

connectDragEnter
ulong connectDragEnter(T callback, Flag!"After" after)

Connect to DragEnter signal.

connectDragLeave
ulong connectDragLeave(T callback, Flag!"After" after)

Connect to DragLeave signal.

connectDragMotion
ulong connectDragMotion(T callback, Flag!"After" after)

Connect to DragMotion signal.

connectDrop
ulong connectDrop(T callback, Flag!"After" after)

Connect to Drop signal.

getActions
gdk.types.DragAction getActions()

Gets the actions that this drop target supports.

getFormats
gdk.content_formats.ContentFormats getFormats()

Gets the data formats that this drop target accepts.

rejectDrop
void rejectDrop(gdk.drop.Drop drop)

Sets the drop as not accepted on this drag site.

setActions
void setActions(gdk.types.DragAction actions)

Sets the actions that this drop target supports.

setFormats
void setFormats(gdk.content_formats.ContentFormats formats)

Sets the data formats that this drop target will accept.

Inherited Members

From EventController

getCurrentEvent
gdk.event.Event getCurrentEvent()

Returns the event that is currently being handled by the controller.

getCurrentEventDevice
gdk.device.Device getCurrentEventDevice()

Returns the device of the event that is currently being handled by the controller.

getCurrentEventState
gdk.types.ModifierType getCurrentEventState()

Returns the modifier state of the event that is currently being handled by the controller.

getCurrentEventTime
uint getCurrentEventTime()

Returns the timestamp of the event that is currently being handled by the controller.

getName
string getName()

Gets the name of controller.

getPropagationLimit
gtk.types.PropagationLimit getPropagationLimit()

Gets the propagation limit of the event controller.

getPropagationPhase
gtk.types.PropagationPhase getPropagationPhase()

Gets the propagation phase at which controller handles events.

getWidget
gtk.widget.Widget getWidget()

Returns the gtk.widget.Widget this controller relates to.

reset
void reset()

Resets the controller to a clean state.

setName
void setName(string name)

Sets a name on the controller that can be used for debugging.

setPropagationLimit
void setPropagationLimit(gtk.types.PropagationLimit limit)

Sets the event propagation limit on the event controller.

setPropagationPhase
void setPropagationPhase(gtk.types.PropagationPhase phase)

Sets the propagation phase at which a controller handles events.

setStaticName
void setStaticName(string name)

Sets a name on the controller that can be used for debugging.