# rmp::behavior::Draggable

> Picked up with the pointer and put down somewhere.

Source: https://omardev29.github.io/rmp-docs/reference/behaviors/Draggable.html

behavior `#include <rmp/behavior.h>` [include/rmp/behavior.h:983](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/behavior.h#L983-L1018)

struct Draggable

Picked up with the pointer and put down somewhere. It takes the object's on_drag. Let go over an object with an Area — on a layer of `drop_on`, and `accepts` saying yes — it is dropped there: on_drop, and centred on it with `centre_on_drop`. Let go anywhere else it goes back where it was picked up, with `return_if_rejected`, or stays, snapped to `snap`, and with `throwable` keeps the pointer's speed and slides to a stop.

Added to an object with `add<rmp::behavior::Draggable>()`; the framework calls its `_ready`, `_update` with the object it is on.

## Fields

| Field | Type | Default | What it is |
|---|---|---|---|
| `snap` | `Vector2` | `{}` | The grid it lands on; {0,0} = none |
| `throwable` | `bool` | `false` | Keeps the pointer's speed when let go |
| `friction` | `float` | `6` | How fast a throw slows: the share of its speed lost per second |
| `bounds` | `Rectangle` | `{}` | Where it can be dragged; {0,0,0,0} = anywhere |
| `drop_on` | `unsigned` | `0xFFFFFFFFu` | The layers of the Areas it can be dropped on |
| `return_if_rejected` | `bool` | `true` | No Area took it: back where it was picked up |
| `centre_on_drop` | `bool` | `true` | Dropped on an Area: put on its centre |
| `accepts` | `Condition<Object &, Object &>` |  | (this, the area); empty = every Area does |
| `on_pick` | `Callback<Object &>` |  | The first time it moves under the pointer |
| `on_drop` | `Callback<Object &, Object &>` |  | (this, the area it was dropped on) |
| `on_reject` | `Callback<Object &>` |  | Let go where no Area took it |
| `ours` | `struct { … }` |  | What it is keeping track of. Readable, because sometimes you want it; not yours to write. It is one PUBLIC member and not a private block because a struct with a private member is not an aggregate in C++20, and then `{ .speed = 320 }` stops compiling — which is the whole design. The name is the fence. |

### `held`

bool held() const

function [include/rmp/behavior.h:997](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/behavior.h#L997)

Whether the pointer holds it now.

### `drop`

void drop(Object &self)

function [include/rmp/behavior.h:1000](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/behavior.h#L1000)

Lets go of it here, as the pointer letting go would: onto the Area under it, or back, or where it is.
