Package: gtk

Class gtk:drag-source

Superclasses

gtk:gesture-single, gtk:gesture, gtk:event-controller, gobject:object, common-lisp:standard-object, common-lisp:t

Documented Subclasses

None

Direct Slots

actions
The actions property of type gdk:drag-action (Read / Write)
The actions that are supported by drag operations from the source. Note that you must handle the "drag-end" signal if the actions include :move.
Default value: :copy
content
The content property of type gdk:content-provider (Read / Write)
The data that is offered by drag operations from this source, in the form of a gdk:content-provider object.

Details

The gtk:drag-source object is an auxiliary object that is used to initiate Drag and Drop operations. It can be set up with the necessary ingredients for a DND operation ahead of time. This includes the source for the data that is being transferred, in the form of a gdk:content-provider object, the desired action, and the icon to use during the drag operation. After setting it up, the drag source must be added to a widget as an event controller, using the gtk:widget-add-controller function.

Setting up the content provider and icon ahead of time only makes sense when the data does not change. More commonly, you will want to set them up just in time. To do so, the gtk:drag-source object has "prepare" and "drag-begin" signals. The "prepare" signal is emitted before a drag is started, and can be used to set the content provider and actions that the drag should be started with. The "drag-begin" signal is emitted after the gdk:drag object has been created, and can be used to set up the drag icon.

During the DND operation, the gtk:drag-source object emits signals that can be used to obtain updates about the status of the operation, but it is not normally necessary to connect to any signals, except for one case. When the supported actions include the :move value of the gdk:drag-action flags, you need to listen for the "drag-end" signal and delete the data after it has been transferred.

Signal Details

The "drag-begin" signal
lambda (source drag)    :run-last      
source
The gtk:drag-source object.
drag
The gdk:drag object.
The signal is emitted on the drag source when a drag is started. It can be used to, for example, set a custom drag icon with the gtk:drag-source-set-icon function.
The "drag-cancel" signal
lambda (source drag reason)    :run-last      
source
The gtk:drag-source object.
drag
The gdk:drag object.
reason
The gdk:drag-cancel-reason value with the information on why the drag failed.
Returns
True if the failed drag operation has been already handled.
The signal is emitted on the drag source when a drag has failed. The signal handler may handle a failed drag operation based on the type of error. It should return true if the failure has been handled and the default "drag operation failed" animation should not be shown.
The "drag-end" signal
lambda (source drag delete)    :run-last      
source
The gtk:drag-source object.
drag
The gdk:drag object.
delete
True if the drag was performing :move, and the data should be deleted.
Returns
True if the failed drag operation has been already handled.
The signal is emitted on the drag source when a drag is finished. A typical reason to connect to this signal is to undo things done in the "prepare" or "drag-begin" handler.
The "prepare" signal
lambda (source x y)    :run-last      
source
The gtk:drag-source object.
x
The double float with the x coordinate of the drag starting point.
y
The double float with the y coordinate of the drag starting point.
Returns
The gdk:content-provider object, or nil.
The signal is emitted when a drag is about to be initiated. It returns the gdk:content-provider object to use for the drag that is about to start. The default handler for this signal returns the value of the content property, so if you set up that property ahead of time, you do not need to connect to this signal.
 

Returned by

Slot Access Functions

Inherited Slot Access Functions

2024-11-2