Signals
| Chapter 17. Drag and Drop |

## Signals

When a drop target has accepted a dragged item, certain signals will be emitted, depending on what action has been selected. For instance, the user might have held down the Shift key to specify a `move` rather than a `copy`. Remember that the user can only select the actions which you have specified in your calls to `Gtk::DragSource::set_actions()` and `Gtk::DropTarget::set_actions()`.

The source widget will emit these `DragSource` signals:

- `drag_begin`: Provides a `Gdk::Drag`.

- `prepare`: Shall return a `Gdk::ContentProvider`, with the data to use for the drag that is about to start.

- `drag_end`: Provides a `Gdk::Drag`, and a bool that tells if the drag was performing a `move` and the data should be deleted.

- `drag_cancel`: Emitted on the drag source when a drag has failed.

The target widget will emit these `DropTarget` signals:

- `enter`: Provides coordinates. Shall return the preferred Gdk::DragAction.

- `motion`: Provides coordinates. Shall return the preferred Gdk::DragAction.

- `leave`: Emitted on the drop site when the pointer leaves the widget.

- `accept`: Provides a `Gdk::Drop`. You can call the `status()` method of the `Gdk::Drop` to indicate which actions will be accepted.

- `drop`: Provides the data being dropped and coordinates. Shall return a bool indicating whether the drop was accepted.

The following signals call only one signal handler when emitted. When you connect a handler to such a signal, your signal handler must be called before (instead of) the default handler, otherwise it won't be called. Set the `after` parameter in `connect()` to `false`.

- `Gtk::DragSource::signal_prepare()`

- `Gtk::DropTarget::signal_enter()`

- `Gtk::DropTarget::signal_motion()`

- `Gtk::DropTarget::signal_accept()`

- `Gtk::DropTarget::signal_drop()`

Methods |  | Example