class Gdk::Drag

Overview

The Gdk::Drag object represents the source of an ongoing DND operation.

A Gdk::Drag is created when a drag is started, and stays alive for duration of the DND operation. After a drag has been started with Gdk::Drag#begin, the caller gets informed about the status of the ongoing drag operation with signals on the Gdk::Drag 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.

Defined in:

lib/gi-crystal/src/auto/gdk-4.0/drag.cr

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from class GObject::Object

==(other : self) ==, bind_property(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags) : GObject::Binding bind_property, bind_property_full(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags, transform_to : GObject::Closure, transform_from : GObject::Closure) : GObject::Binding bind_property_full, data(key : String) : Pointer(Void) | Nil data, finalize finalize, freeze_notify : Nil freeze_notify, getv(names : Enumerable(String), values : Enumerable(_)) : Nil getv, hash(hasher) hash, notify(property_name : String) : Nil notify, notify_by_pspec(pspec : GObject::ParamSpec) : Nil notify_by_pspec, notify_signal notify_signal, property(property_name : String, value : _) : Nil property, qdata(quark : UInt32) : Pointer(Void) | Nil qdata, ref_count : UInt32 ref_count, run_dispose : Nil run_dispose, set_data(key : String, data : Pointer(Void) | Nil) : Nil set_data, set_property(property_name : String, value : _) : Nil set_property, steal_data(key : String) : Pointer(Void) | Nil steal_data, steal_qdata(quark : UInt32) : Pointer(Void) | Nil steal_qdata, thaw_notify : Nil thaw_notify, to_unsafe : Pointer(Void) to_unsafe, watch_closure(closure : GObject::Closure) : Nil watch_closure

Constructor methods inherited from class GObject::Object

cast(obj : GObject::Object) : self cast, new(pointer : Pointer(Void), transfer : GICrystal::Transfer)
new
new
, newv(object_type : UInt64, parameters : Enumerable(GObject::Parameter)) : self newv

Class methods inherited from class GObject::Object

cast?(obj : GObject::Object) : self | Nil cast?, compat_control(what : UInt64, data : Pointer(Void) | Nil) : UInt64 compat_control, g_type : UInt64 g_type, interface_find_property(g_iface : GObject::TypeInterface, property_name : String) : GObject::ParamSpec interface_find_property, interface_list_properties(g_iface : GObject::TypeInterface) : Enumerable(GObject::ParamSpec) interface_list_properties

Constructor Detail

def self.new #

Initialize a new Drag.


[View source]
def self.new(*, actions : Gdk::DragAction | Nil = nil, content : Gdk::ContentProvider | Nil = nil, device : Gdk::Device | Nil = nil, display : Gdk::Display | Nil = nil, formats : Gdk::ContentFormats | Nil = nil, selected_action : Gdk::DragAction | Nil = nil, surface : Gdk::Surface | Nil = nil) #

[View source]

Class Method Detail

def self.begin(surface : Gdk::Surface, device : Gdk::Device, content : Gdk::ContentProvider, actions : Gdk::DragAction, dx : Float64, dy : Float64) : Gdk::Drag | Nil #

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 Gdk::Drag#drag_surface.

This function returns a reference to the Gdk::Drag object, but GTK keeps its own reference as well, as long as the DND operation is going on.

Note: if actions include %GDK_ACTION_MOVE, you need to listen for the [signal@Gdk.Drag::dnd-finished] signal and delete the data at the source if Gdk::Drag#selected_action returns %GDK_ACTION_MOVE.


[View source]
def self.g_type : UInt64 #

Returns the type id (GType) registered in GLib type system.


[View source]

Instance Method Detail

def ==(other : self) #
Description copied from class Reference

Returns true if this reference is the same as other. Invokes same?.


def actions : Gdk::DragAction #

Determines the bitmask of possible actions proposed by the source.


[View source]
def actions=(value : Gdk::DragAction) : Gdk::DragAction #

[View source]
def cancel_signal #

[View source]
def content : Gdk::ContentProvider #

Returns the Gdk::ContentProvider associated to the Gdk::Drag object.


[View source]
def content=(value : Gdk::ContentProvider | Nil) : Gdk::ContentProvider | Nil #

[View source]
def device : Gdk::Device #

Returns the Gdk::Device associated to the Gdk::Drag object.


[View source]
def device=(value : Gdk::Device | Nil) : Gdk::Device | Nil #

[View source]
def display : Gdk::Display #

Gets the Gdk::Display that the drag object was created for.


[View source]
def dnd_finished_signal #

[View source]
def drag_surface : Gdk::Surface | Nil #

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 drag and will be destroyed when the drag operation is over.


[View source]
def drop_done(success : Bool) : Nil #

Informs GDK that the drop ended.

Passing false for success 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 drag.

The Gdk::Drag will only take the first Gdk::Drag#drop_done call as effective, if this function is called multiple times, all subsequent calls will be ignored.


[View source]
def drop_performed_signal #

[View source]
def formats : Gdk::ContentFormats #

Retrieves the formats supported by this Gdk::Drag object.


[View source]
def formats=(value : Gdk::ContentFormats | Nil) : Gdk::ContentFormats | Nil #

[View source]
def hash(hasher) #
Description copied from class Reference

See Object#hash(hasher)


def selected_action : Gdk::DragAction #

Determines the action chosen by the drag destination.


[View source]
def selected_action=(value : Gdk::DragAction) : Gdk::DragAction #

[View source]
def set_hotspot(hot_x : Int32, hot_y : Int32) : Nil #

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.


[View source]
def surface : Gdk::Surface #

Returns the Gdk::Surface where the drag originates.


[View source]
def surface=(value : Gdk::Surface | Nil) : Gdk::Surface | Nil #

[View source]