# Draggable Element

## 🎛️ DraggableElement Class

Defines a draggable UI button element.

> **Namespace:** `Esper.Inventool.UI`\
> **Access:** `public`\
> **Type:** `class`\
> **Inherits:** `Button`\
> **Attributes:** `[UxmlElement]`

***

### 📦 Fields

| Access      | Field                 | Type         | Description                           |
| ----------- | --------------------- | ------------ | ------------------------------------- |
| `protected` | `pointerDown`         | `bool`       | True while pointer is held down.      |
| `protected` | `dragStarted`         | `bool`       | True once dragging has begun.         |
| `protected` | `dragAllowedGetter`   | `Func<bool>` | Determines if dragging is allowed.    |
| `public`    | `onDragStarted`       | `Action`     | Callback when drag begins.            |
| `public`    | `onDrag`              | `Action`     | Callback during dragging.             |
| `public`    | `onDropped`           | `Action`     | Callback when drag ends (dropped).    |
| `protected` | `pointerMovePosition` | `Vector2`    | Latest pointer position.              |
| `protected` | `pointerDownPosition` | `Vector2`    | Pointer position at drag start.       |
| `public`    | `isPointerInside`     | `bool`       | True if pointer is over this element. |

***

### 🧰 Methods

| Access      | Method                                    | Returns | Description                                 |
| ----------- | ----------------------------------------- | ------- | ------------------------------------------- |
| `public`    | `DraggableElement()`                      | —       | Constructor wiring pointer event callbacks. |
| `public`    | `ForceStopDrag()`                         | `void`  | Cancels any ongoing drag.                   |
| `protected` | `WaitForDrag(PointerDownEvent downEvent)` | `void`  | Begin drag check on left-button down.       |
| `protected` | `Drag(PointerMoveEvent moveEvent)`        | `void`  | Handle pointer movement during drag.        |
| `protected` | `Drop(PointerUpEvent upEvent)`            | `void`  | Complete drag on left-button release.       |

***
