Gtk.Widget::drag-data-received
function callback(widget, context:Gdk.DragContext, x:Number, y:Number, data:Gtk.SelectionData, info:Number, time:Number, ):void;
The ::drag-data-received signal is emitted on the drop site when the dragged data has been received. If the data was received in order to determine whether the drop will be accepted, the handler is expected to call Gdk.drag_status and <emphasis>not</emphasis> finish the drag. If the data was received in response to a Gtk.drag-drop signal (and this is the last target to be received), the handler for this signal is expected to process the received data and then call drag_finish, setting the @success parameter depending on whether the data was processed successfully.
The handler may inspect the selected action with Gdk.get_selected_action before calling drag_finish, e.g. to implement Gdk.DragAction.ask as shown in the following example: |[ void drag_data_received (GtkWidget *widget, GdkDragContext *context, gint x, gint y, GtkSelectionData *data, guint info, guint time) { if ((data->length >= 0) && (data->format == 8)) { GdkDragAction action;
/* handle data here */
action = gdk_drag_context_get_selected_action (context); if (action == GDK_ACTION_ASK) { GtkWidget *dialog; gint response;
dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_INFO, GTK_BUTTONS_YES_NO, "Move the data ?\n"); response = gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog);
if (response == GTK_RESPONSE_YES) action = GDK_ACTION_MOVE; else action = GDK_ACTION_COPY; }
gtk_drag_finish (context, TRUE, action == GDK_ACTION_MOVE, time); } else gtk_drag_finish (context, FALSE, FALSE, time); } ]|
- widget
instance of Gtk.Widget that is emitting the signal
- context
the drag context
- x
where the drop happened
- y
where the drop happened
- data
the received data
- info
the info that has been registered with the target in the Gtk.TargetList
- time
the timestamp at which the data was received