Class DropTarget.Builder<B extends DropTarget.Builder<B>>
- Type Parameters:
B
- the type of the Builder that is returned
- All Implemented Interfaces:
BuilderInterface
- Enclosing class:
DropTarget
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Finish building theDropTarget
object.onAccept
(DropTarget.AcceptCallback handler) Emitted on the drop site when a drop operation is about to begin.onDrop
(DropTarget.DropCallback handler) Emitted on the drop site when the user drops the data onto the widget.onEnter
(DropTarget.EnterCallback handler) Emitted on the drop site when the pointer enters the widget.onLeave
(DropTarget.LeaveCallback handler) Emitted on the drop site when the pointer leaves the widget.onMotion
(DropTarget.MotionCallback handler) Emitted while the pointer is moving over the drop target.setActions
(Set<DragAction> actions) TheGdkDragActions
that this drop target supports.setActions
(DragAction... actions) TheGdkDragActions
that this drop target supports.setFormats
(ContentFormats formats) TheGdkContentFormats
that determine the supported data formats.setPreload
(boolean preload) Whether the drop data should be preloaded when the pointer is only hovering over the widget but has not been released.Methods inherited from class org.gnome.gtk.EventController.Builder
setName, setPropagationLimit, setPropagationPhase
Methods inherited from class org.gnome.gobject.GObject.Builder
onNotify
Methods inherited from class io.github.jwharm.javagi.gobject.Builder
addBuilderProperty, connect, connect, connectSignals, getArena, getNames, getValues
-
Constructor Details
-
Builder
protected Builder()Default constructor for aBuilder
object.
-
-
Method Details
-
build
Finish building theDropTarget
object. This will callGObject.withProperties(org.gnome.glib.Type, java.lang.String[], org.gnome.gobject.Value[])
to create a new GObject instance, which is then cast toDropTarget
.- Overrides:
build
in classEventController.Builder<B extends DropTarget.Builder<B>>
- Returns:
- a new instance of
DropTarget
with the properties that were set in the Builder object.
-
setActions
TheGdkDragActions
that this drop target supports.- Parameters:
actions
- the value for theactions
property- Returns:
- the
Builder
instance is returned, to allow method chaining
-
setFormats
TheGdkContentFormats
that determine the supported data formats.- Parameters:
formats
- the value for theformats
property- Returns:
- the
Builder
instance is returned, to allow method chaining
-
setPreload
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
GDK_TYPE_RGBA
), so enabling this property does not hurt at all. And for local-only Drag-and-Drop operations, no data transfer is done, so enabling it there is free.- Parameters:
preload
- the value for thepreload
property- Returns:
- the
Builder
instance is returned, to allow method chaining
-
setActions
TheGdkDragActions
that this drop target supports.- Parameters:
actions
- the value for theactions
property- Returns:
- the
Builder
instance is returned, to allow method chaining
-
onAccept
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. Iftrue
is returned, the drop is accepted for now but may be rejected later via a call toDropTarget.reject()
or ultimately by returningfalse
from aGtk.DropTarget::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 depends on the data, this function should return
true
, theGtk.DropTarget:preload
property should be set and the value should be inspected via the ::notify:value signal, callingDropTarget.reject()
if required.- Parameters:
handler
- the signal handler- Returns:
- the
Builder
instance is returned, to allow method chaining - See Also:
-
onDrop
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 using the givenvalue
and performing the drop operation.- Parameters:
handler
- the signal handler- Returns:
- the
Builder
instance is returned, to allow method chaining - See Also:
-
onEnter
Emitted on the drop site when the pointer enters the widget.It can be used to set up custom highlighting.
- Parameters:
handler
- the signal handler- Returns:
- the
Builder
instance is returned, to allow method chaining - See Also:
-
onLeave
Emitted on the drop site when the pointer leaves the widget.Its main purpose it to undo things done in
Gtk.DropTarget::enter
.- Parameters:
handler
- the signal handler- Returns:
- the
Builder
instance is returned, to allow method chaining - See Also:
-
onMotion
Emitted while the pointer is moving over the drop target.- Parameters:
handler
- the signal handler- Returns:
- the
Builder
instance is returned, to allow method chaining - See Also:
-