Class Drag
- All Implemented Interfaces:
Proxy
- Direct Known Subclasses:
Drag.Drag$Impl
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
Nested ClassesModifier and TypeClassDescriptionstatic classDrag.Builder<B extends Drag.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static interfaceFunctional interface declaration of theCancelCallbackcallback.static interfaceFunctional interface declaration of theDndFinishedCallbackcallback.static classThe Drag$Impl type represents a native instance of the abstract Drag class.static interfaceFunctional interface declaration of theDropPerformedCallbackcallback.Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass -
Constructor Summary
ConstructorsConstructorDescriptionDrag()Creates a new Drag.Drag(MemorySegment address) Create a Drag proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected DragasParent()Returns this instance as if it were its parent type.static @Nullable Dragbegin(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 @Nullable Dragbegin(Surface surface, Device device, ContentProvider content, DragAction actions, double dx, double dy) Starts a drag and creates a new drag context for it.voiddropDone(boolean success) Informs GDK that the drop ended.voidemitCancel(DragCancelReason reason) Emits the "cancel" signal.voidEmits the "dnd-finished" signal.voidEmits the "drop-performed" signal.Determines the bitmask of possible actions proposed by the source.Returns theGdkContentProviderassociated to theGdkDragobject.Returns theGdkDeviceassociated to theGdkDragobject.Gets theGdkDisplaythat the drag object was created for.@Nullable SurfaceReturns the surface on which the drag icon should be rendered during the drag operation.Retrieves the formats supported by thisGdkDragobject.Determines the action chosen by the drag destination.Returns theGdkSurfacewhere the drag originates.static @Nullable TypegetType()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.voidsetHotspot(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, builder, 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, 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, withPropertiesMethods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class org.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
-
Drag
public Drag()Creates a new Drag.
-
-
Method Details
-
getType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuperkeyword, 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 @Nullable 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
Dragobject, but GTK keeps its own reference as well, as long as the DND operation is going on.Note: if
actionsincludeDragAction.MOVE, you need to listen for theGdk.Drag::dnd-finishedsignal 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'sposition where the drag nominally starteddy- the y offset todevice'sposition where the drag nominally started- Returns:
- a newly created
GdkDrag
-
begin
public static @Nullable 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
Dragobject, but GTK keeps its own reference as well, as long as the DND operation is going on.Note: if
actionsincludeDragAction.MOVE, you need to listen for theGdk.Drag::dnd-finishedsignal 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'sposition where the drag nominally starteddy- the y offset todevice'sposition where the drag nominally started- Returns:
- a newly created
GdkDrag
-
dropDone
public void dropDone(boolean success) Informs GDK that the drop ended.Passing
falseforsuccessmay 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
drag.The
GdkDragwill 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
GdkDragActionflags
-
getContent
Returns theGdkContentProviderassociated to theGdkDragobject.- Returns:
- The
GdkContentProviderassociated todrag.
-
getDevice
Returns theGdkDeviceassociated to theGdkDragobject.- Returns:
- The
GdkDeviceassociated todrag.
-
getDisplay
Gets theGdkDisplaythat 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 thisGdkDragobject.- Returns:
- a
GdkContentFormats
-
getSelectedAction
Determines the action chosen by the drag destination.- Returns:
- a
GdkDragActionvalue
-
getSurface
Returns theGdkSurfacewhere the drag originates.- Returns:
- The
GdkSurfacewhere 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).
-