Package: gtk

Class gtk:drop-target

Superclasses

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 this drop target supports.
Default value: :none
current-drop
The current-drop property of type gdk:drop (Read)
The drop that is currently being performed. Since 4.4
drop
The drop property of type gdk:drop (Read)
The drop that is currently being performed. Deprecated 4.4
formats
The formats property of type gdk:content-formats (Read)
The content formats that determine the supported data formats.
preload
The preload property of type :boolean (Read / Write)
Whether the drop data should be preloaded when the pointer is only hovering over the widget but has not been released. Setting this property allows finer grained reaction to an ongoing drop at the cost of loading more data. The default value for this property is false to avoid downloading huge amounts of data by accident. For example, if somebody drags a full document of gigabytes of text from a text editor across a widget with a preloading drop target, this data will be downloaded, even if the data is ultimately dropped elsewhere. For a lot of data formats, the amount of data is very small, like the gdk:rgba color, so enabling this property does not hurt at all. And for local-only drag'n'drop operations, no data transfer is done, so enabling it there is free.
Default value: false
value
The value property of type g:value (Read)
The value for this drop operation or nil if the data has not been loaded yet or no drop operation is going on. Data may be available before the "current-drop" signal gets emitted - for example when the preload property is set. You can use the "notify" signal to be notified of available data.

Details

The gtk:drop-target object is an event controller implementing a simple way to receive Drag-and-Drop operations. The most basic way to use a gtk:drop-target object to receive drops on a widget is to create it via the gtk:drop-target-new function passing in the GType of the data you want to receive and connect to the "current-drop" signal to receive the data.

The gtk:drop-target object supports more options, such as:
  • rejecting potential drops via the "accept" signal and the gtk:drop-target-reject function to let other drop targets handle the drop
  • tracking an ongoing drag operation before the drop via the "enter", "motion" and "leave" signals
  • configuring how to receive data by setting the preload property and listening for its availability via the value property
However, the gtk:drop-target object is ultimately modeled in a synchronous way and only supports data transferred via GType. If you want full control over an ongoing drop, the gtk:drop-target-async object gives you this ability.

While a pointer is dragged over the drop target's widget and the drop has not been rejected, that widget will receive the :drop-active state, which can be used to style the widget.

Signal Details

The "accept" signal
lambda (target drop)    :run-last      
target
The gtk:drag-target object.
drop
The gdk:drop object.
Returns
True if drop is accepted.
The signal is 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 the gtk:drop-target-reject function or ultimately by returning false from the "drop" signal.

The default handler for this signal decides whether to accept the drop based on the formats provided by drop.

If the decision whether the drop will be accepted or rejected needs inspecting the data, this function should return true, the preload property should be set and the value should be inspected via the "notify::value" signal and then call the gtk:drop-target-reject function.
The "drop" signal
lambda (target value x y)    :run-last      
target
The gtk:drag-target object.
value
The g:value instance being dropped.
x
The double float with the x coordinate of the current pointer position.
y
The double float with the x coordinate of the current pointer position.
Returns
Whether the drop was accepted at the given pointer position.
The signal is 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 is responsible for reading the given value and performing the drop operation.
The "enter" signal
lambda (target x y)    :run-last      
target
The gtk:drag-target object.
x
A double float with the x coordinate of the current pointer position.
y
A double float with the x coordinate of the current pointer position.
Returns
A gdk:drag-action value with the preferred action for this drag operation or 0 if dropping is not supported at the current x,y location.
The signal is emitted on the drop site when the pointer enters the widget. It can be used to set up custom highlighting.
The "leave" signal
lambda (target)    :run-last      
target
The gtk:drag-target object.
The signal is emitted on the drop site when the pointer leaves the widget. Its main purpose is to undo things done in the "enter" signal handler.
The "motion" signal
lambda (target x y)    :run-last      
target
The gtk:drag-target object.
x
The double float with the x coordinate of the current pointer position.
y
The double float with the x coordinate of the current pointer position.
Returns
The gdk:drag-action value with the preferred action for this drag operation or 0 if dropping is not supported at the current x,y location.
The signal is emitted while the pointer is moving over the drop target.
 

Returned by

Slot Access Functions

Inherited Slot Access Functions

See also

2023-9-18