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

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)? data, finalize finalize, freeze_notify : Nil freeze_notify, getv(names : Enumerable(String), values : Enumerable(_)) : Nil getv, 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)? qdata, ref_count : UInt32 ref_count, run_dispose : Nil run_dispose, set_data(key : String, data : Pointer(Void)?) : Nil set_data, set_property(property_name : String, value : _) : Nil set_property, steal_data(key : String) : Pointer(Void)? steal_data, steal_qdata(quark : UInt32) : Pointer(Void)? 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, 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

compat_control(what : UInt64, data : Pointer(Void)?) : 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.


def self.new(*, actions : Gdk::DragAction? = nil, content : Gdk::ContentProvider? = nil, device : Gdk::Device? = nil, display : Gdk::Display? = nil, formats : Gdk::ContentFormats? = nil, selected_action : Gdk::DragAction? = nil, surface : Gdk::Surface? = nil) #

Class Method Detail

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

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.


def self.g_type : UInt64 #

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


Instance Method Detail

def actions : Gdk::DragAction #

Determines the bitmask of possible actions proposed by the source.


def actions=(value : Gdk::DragAction) : Gdk::DragAction #

def cancel_signal #

def content : Gdk::ContentProvider #

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


def content=(value : Gdk::ContentProvider?) : Gdk::ContentProvider? #

def device : Gdk::Device #

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


def device=(value : Gdk::Device?) : Gdk::Device? #

def display : Gdk::Display #

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


def dnd_finished_signal #

def drag_surface : Gdk::Surface? #

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.


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.


def drop_performed_signal #

def formats : Gdk::ContentFormats #

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


def formats=(value : Gdk::ContentFormats?) : Gdk::ContentFormats? #

def selected_action : Gdk::DragAction #

Determines the action chosen by the drag destination.


def selected_action=(value : Gdk::DragAction) : Gdk::DragAction #

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.


def surface : Gdk::Surface #

Returns the Gdk::Surface where the drag originates.


def surface=(value : Gdk::Surface?) : Gdk::Surface? #