Gtk.Widget.prototype.drag_begin
function drag_begin(targets:Gtk.TargetList, actions:Gdk.DragAction, button:Number, event:Gdk.Event):Gdk.DragContext { // Gjs wrapper for gtk_drag_begin() }
Initiates a drag on the source side. The function only needs to be used when the application is starting drags itself, and is not needed when Gtk.drag_source_set is used.
The event is used to retrieve the timestamp that will be used internally to grab the pointer. If event is #NULL, then GDK_CURRENT_TIME will be used. However, you should try to pass a real event in all cases, since that can be used by GTK+ to get information about the start position of the drag, for example if the event is a Gdk.EventType.motion_notify.
Generally there are three cases when you want to start a drag by hand by calling this function:
1. During a Gtk.button-press-event handler, if you want to start a drag immediately when the user presses the mouse button. Pass the event that you have in your Gtk.button-press-event handler.
2. During a Gtk.motion-notify-event handler, if you want to start a drag when the mouse moves past a certain threshold distance after a button-press. Pass the event that you have in your Gtk.motion-notify-event handler.
3. During a timeout handler, if you want to start a drag after the mouse button is held down for some time. Try to save the last event that you got from the mouse, using Gdk.copy, and pass it to this function (remember to free the event with Gdk.free when you are done). If you can really not pass a real event, pass #NULL instead.
- targets
The targets (data formats) in which the source can provide the data.
- actions
A bitmask of the allowed drag actions for this drag.
- button
The button the user clicked to start the drag.
- event
The event that triggered the start of the drag.
- Returns
the context for this drag.