Class Drag
- All Implemented Interfaces:
Proxy
- Direct Known Subclasses:
Drag.DragImpl
GdkDrag
object represents the source of an ongoing DND operation.
A GdkDrag
is created when a drag is started, and stays alive for duration of
the DND operation. After a drag has been started with begin(org.gnome.gdk.Surface, org.gnome.gdk.Device, org.gnome.gdk.ContentProvider, java.util.Set<org.gnome.gdk.DragAction>, double, double)
,
the caller gets informed about the status of the ongoing drag operation
with signals on the GdkDrag
object.
GTK provides a higher level abstraction based on top of these functions, and so they are not normally needed in GTK applications. See the "Drag and Drop" section of the GTK documentation for more information.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Drag.Builder<B extends Drag.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static interface
Functional interface declaration of theCancelCallback
callback.static interface
Functional interface declaration of theDndFinishedCallback
callback.static class
The DragImpl type represents a native instance of the abstract Drag class.static interface
Functional interface declaration of theDropPerformedCallback
callback.Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
-
Constructor Summary
ConstructorDescriptionDrag
(MemorySegment address) Create a Drag proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected Drag
asParent()
Returns this instance as if it were its parent type.static Drag
begin
(Surface surface, Device device, ContentProvider content, Set<DragAction> actions, double dx, double dy) Starts a drag and creates a new drag context for it.static Drag
begin
(Surface surface, Device device, ContentProvider content, DragAction actions, double dx, double dy) Starts a drag and creates a new drag context for it.static Drag.Builder
<? extends Drag.Builder> builder()
ADrag.Builder
object constructs aDrag
with the specified properties.void
dropDone
(boolean success) Informs GDK that the drop ended.void
emitCancel
(DragCancelReason reason) Emits the "cancel" signal.void
Emits the "dnd-finished" signal.void
Emits the "drop-performed" signal.Determines the bitmask of possible actions proposed by the source.Returns theGdkContentProvider
associated to theGdkDrag
object.Returns theGdkDevice
associated to theGdkDrag
object.Gets theGdkDisplay
that the drag object was created for.Returns the surface on which the drag icon should be rendered during the drag operation.Retrieves the formats supported by thisGdkDrag
object.Determines the action chosen by the drag destination.Returns theGdkSurface
where the drag originates.static Type
getType()
Get the GType of the Drag classonCancel
(Drag.CancelCallback handler) Emitted when the drag operation is cancelled.onDndFinished
(Drag.DndFinishedCallback handler) Emitted when the destination side has finished reading all data.Emitted when the drop operation is performed on an accepting client.void
setHotspot
(int hotX, int hotY) Sets the position of the drag surface that will be kept under the cursor hotspot.Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getMemoryLayout, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newInstance, newInstance, newv, notify_, notify_, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
Drag
Create a Drag proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
-
Method Details
-
getType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()
doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName()
. This will call the native function pointer of this virtual method in the typeclass of the parent type. -
begin
public static Drag begin(Surface surface, Device device, ContentProvider content, Set<DragAction> actions, double dx, double dy) Starts a drag and creates a new drag context for it.This function is called by the drag source. After this call, you probably want to set up the drag icon using the surface returned by
getDragSurface()
.This function returns a reference to the
Drag
object, but GTK keeps its own reference as well, as long as the DND operation is going on.Note: if
actions
includeDragAction.MOVE
, you need to listen for theGdk.Drag::dnd-finished
signal and delete the data at the source ifgetSelectedAction()
returnsDragAction.MOVE
.- Parameters:
surface
- the source surface for this dragdevice
- the device that controls this dragcontent
- the offered contentactions
- the actions supported by this dragdx
- the x offset todevice
's position where the drag nominally starteddy
- the y offset todevice
's position where the drag nominally started- Returns:
- a newly created
GdkDrag
-
begin
public static Drag begin(Surface surface, Device device, ContentProvider content, DragAction actions, double dx, double dy) Starts a drag and creates a new drag context for it.This function is called by the drag source. After this call, you probably want to set up the drag icon using the surface returned by
getDragSurface()
.This function returns a reference to the
Drag
object, but GTK keeps its own reference as well, as long as the DND operation is going on.Note: if
actions
includeDragAction.MOVE
, you need to listen for theGdk.Drag::dnd-finished
signal and delete the data at the source ifgetSelectedAction()
returnsDragAction.MOVE
.- Parameters:
surface
- the source surface for this dragdevice
- the device that controls this dragcontent
- the offered contentactions
- the actions supported by this dragdx
- the x offset todevice
's position where the drag nominally starteddy
- the y offset todevice
's position where the drag nominally started- Returns:
- a newly created
GdkDrag
-
dropDone
public void dropDone(boolean success) Informs GDK that the drop ended.Passing
false
forsuccess
may trigger a drag cancellation animation.This function is called by the drag source, and should be the last call before dropping the reference to the this Drag.
The
GdkDrag
will only take the firstdropDone(boolean)
call as effective, if this function is called multiple times, all subsequent calls will be ignored.- Parameters:
success
- whether the drag was ultimatively successful
-
getActions
Determines the bitmask of possible actions proposed by the source.- Returns:
- the
GdkDragAction
flags
-
getContent
Returns theGdkContentProvider
associated to theGdkDrag
object.- Returns:
- The
GdkContentProvider
associated to this Drag.
-
getDevice
Returns theGdkDevice
associated to theGdkDrag
object.- Returns:
- The
GdkDevice
associated to this Drag.
-
getDisplay
Gets theGdkDisplay
that the drag object was created for.- Returns:
- a
GdkDisplay
-
getDragSurface
Returns the surface on which the drag icon should be rendered during the drag operation.Note that the surface may not be available until the drag operation has begun. GDK will move the surface in accordance with the ongoing drag operation. The surface is owned by this Drag and will be destroyed when the drag operation is over.
- Returns:
- the drag surface
-
getFormats
Retrieves the formats supported by thisGdkDrag
object.- Returns:
- a
GdkContentFormats
-
getSelectedAction
Determines the action chosen by the drag destination.- Returns:
- a
GdkDragAction
value
-
getSurface
Returns theGdkSurface
where the drag originates.- Returns:
- The
GdkSurface
where the drag originates
-
setHotspot
public void setHotspot(int hotX, int hotY) Sets the position of the drag surface that will be kept under the cursor hotspot.Initially, the hotspot is at the top left corner of the drag surface.
- Parameters:
hotX
- x coordinate of the drag surface hotspothotY
- y coordinate of the drag surface hotspot
-
onCancel
Emitted when the drag operation is cancelled.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitCancel
Emits the "cancel" signal. SeeonCancel(org.gnome.gdk.Drag.CancelCallback)
. -
onDndFinished
Emitted when the destination side has finished reading all data.The drag object can now free all miscellaneous data.
- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitDndFinished
public void emitDndFinished()Emits the "dnd-finished" signal. SeeonDndFinished(org.gnome.gdk.Drag.DndFinishedCallback)
. -
onDropPerformed
public SignalConnection<Drag.DropPerformedCallback> onDropPerformed(Drag.DropPerformedCallback handler) Emitted when the drop operation is performed on an accepting client.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitDropPerformed
public void emitDropPerformed()Emits the "drop-performed" signal. SeeonDropPerformed(org.gnome.gdk.Drag.DropPerformedCallback)
. -
builder
ADrag.Builder
object constructs aDrag
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withDrag.Builder.build()
.
-