Widget.dragBeginWithCoordinates

gdk.drag_context.DragContext dragBeginWithCoordinates(gtk.target_list.TargetList targets, gdk.types.DragAction actions, int button, gdk.event.Event event, int x, int y)

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.widget.Widget.dragSourceSet] 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.types.CURRENT_TIME] will be used. However, you should try to pass a real event in all cases, since that can be used to get information about the drag.

Generally there are three cases when you want to start a drag by hand by calling this function:

  1. During a #GtkWidget::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 #GtkWidget::button-press-event handler.

  1. During a #GtkWidget::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 #GtkWidget::motion-notify-event handler.

  1. 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.event.Event.copy], and pass it to this function (remember to free the event with [gdk.event.Event.free] when you are done). If you really cannot pass a real event, pass null instead.

Parameters

targetsThe targets (data formats) in which the source can provide the data
actionsA bitmask of the allowed drag actions for this drag
buttonThe button the user clicked to start the drag
eventThe event that triggered the start of the drag, or null if none can be obtained.
xThe initial x coordinate to start dragging from, in the coordinate space of widget. If -1 is passed, the coordinates are retrieved from event or the current pointer position
yThe initial y coordinate to start dragging from, in the coordinate space of widget. If -1 is passed, the coordinates are retrieved from event or the current pointer position

Returns

the context for this drag