# UIDragDetector

Roblox Engine API class from Roblox Studio 0.744.0.7441077 (version-7aaa6838d36c4448).

- Inherits from, nearest first: [UIComponent](https://rapi.sleaze.dev/classes/UIComponent.md), [UIBase](https://rapi.sleaze.dev/classes/UIBase.md), [Instance](https://rapi.sleaze.dev/classes/Instance.md), [Object](https://rapi.sleaze.dev/classes/Object.md)
- Memory category: Instances
- HTML page: https://rapi.sleaze.dev/classes/UIDragDetector/
- Roblox documentation: https://create.roblox.com/docs/reference/engine/classes/UIDragDetector

Instance which facilitates and encourages interaction with UI elements in an experience.

## Properties

### BoundingBehavior

```luau
UIDragDetector.BoundingBehavior: Enum.UIDragDetectorBoundingBehavior = Enum.UIDragDetectorBoundingBehavior.Automatic
```

- Tags: Read capabilities: UI

Determines bounding behavior of the dragged UI object when the detector's [`BoundingUI`](https://rapi.sleaze.dev/classes/UIDragDetector.md) is set.

### BoundingUI

```luau
UIDragDetector.BoundingUI: GuiBase2d
```

- Tags: Read capabilities: UI

Instance whose bounding area defines the drag boundaries for the parent [`GuiObject`](https://rapi.sleaze.dev/classes/GuiObject.md).

### DragRelativity

```luau
UIDragDetector.DragRelativity: Enum.UIDragDetectorDragRelativity = Enum.UIDragDetectorDragRelativity.Absolute
```

- Tags: Read capabilities: UI

Sets the paradigm which defines the relativity of inputs/outputs from a custom drag function.

### DragSpace

```luau
UIDragDetector.DragSpace: Enum.UIDragDetectorDragSpace = Enum.UIDragDetectorDragSpace.Parent
```

- Tags: Read capabilities: UI

Sets the paradigm which defines the space of inputs/outputs from a custom drag function.

### DragStyle

```luau
UIDragDetector.DragStyle: Enum.UIDragDetectorDragStyle = Enum.UIDragDetectorDragStyle.TranslatePlane
```

- Tags: Read capabilities: UI

The paradigm used to generate proposed motion.

### Enabled

```luau
UIDragDetector.Enabled: boolean = true
```

- Tags: Read capabilities: UI

Whether the [`UIDragDetector`](https://rapi.sleaze.dev/classes/UIDragDetector.md) responds to user input.

### ReferenceUIInstance

```luau
UIDragDetector.ReferenceUIInstance: GuiObject
```

- Tags: Read capabilities: UI

A [`GuiObject`](https://rapi.sleaze.dev/classes/GuiObject.md) instance whose local space and absolute center position is the reference space and origin for the detector.

### ResponseStyle

```luau
UIDragDetector.ResponseStyle: Enum.UIDragDetectorResponseStyle = Enum.UIDragDetectorResponseStyle.Offset
```

- Tags: Read capabilities: UI

The paradigm used to define the response to proposed motion.

### Selectable

```luau
UIDragDetector.Selectable: boolean = true
```

- Tags: Capabilities: UI

### SelectionModeDragSpeed

```luau
UIDragDetector.SelectionModeDragSpeed: UDim2 = UDim2.new(0, 300, 0, 300)
```

- Tags: Read capabilities: UI

Maximum drag speed for translation.

### SelectionModeRotateSpeed

```luau
UIDragDetector.SelectionModeRotateSpeed: number = 90
```

- Tags: Read capabilities: UI

Maximum angle per second the [`UIDragDetector`](https://rapi.sleaze.dev/classes/UIDragDetector.md) can rotate at.

### UIDragSpeedAxisMapping

```luau
UIDragDetector.UIDragSpeedAxisMapping: Enum.UIDragSpeedAxisMapping = Enum.UIDragSpeedAxisMapping.XY
```

- Tags: Read capabilities: UI

[`UIDragSpeedAxisMapping`](https://rapi.sleaze.dev/classes/UIDragDetector.md) value that determines the **X**/**Y** dimension dragging speeds.

### DragAxis

```luau
UIDragDetector.DragAxis: Vector2 = Vector2.new(1, 0)
```

- Tags: Read capabilities: UI

The drag axis for the [`UIDragDetector`](https://rapi.sleaze.dev/classes/UIDragDetector.md) instance when [`DragStyle`](https://rapi.sleaze.dev/classes/UIDragDetector.md) is set to `UIDragDetectorDragStyle.TranslateLine`.

### MaxDragAngle

```luau
UIDragDetector.MaxDragAngle: number = 0
```

- Tags: Read capabilities: UI

Along with [`MinDragAngle`](https://rapi.sleaze.dev/classes/UIDragDetector.md), impedes the detector's attempts to generate rotational motion.

### MaxDragTranslation

```luau
UIDragDetector.MaxDragTranslation: UDim2 = UDim2.new(0, 0, 0, 0)
```

- Tags: Read capabilities: UI

Along with [`MinDragTranslation`](https://rapi.sleaze.dev/classes/UIDragDetector.md), impedes the detector's attempts to generate linear/planar motion.

### MinDragAngle

```luau
UIDragDetector.MinDragAngle: number = 0
```

- Tags: Read capabilities: UI

Along with [`MaxDragAngle`](https://rapi.sleaze.dev/classes/UIDragDetector.md), impedes the detector's attempts to generate rotational motion.

### MinDragTranslation

```luau
UIDragDetector.MinDragTranslation: UDim2 = UDim2.new(0, 0, 0, 0)
```

- Tags: Read capabilities: UI

Along with [`MaxDragTranslation`](https://rapi.sleaze.dev/classes/UIDragDetector.md), impedes the detector's attempts to generate linear/planar motion.

### DragRotation

```luau
UIDragDetector.DragRotation: number = 0
```

- Tags: Read capabilities: UI

The rotation performed by the current drag.

### DragUDim2

```luau
UIDragDetector.DragUDim2: UDim2 = UDim2.new(0, 0, 0, 0)
```

- Tags: Read capabilities: UI

The translation performed by the current drag expressed in a [`UDim2`](https://rapi.sleaze.dev/index/types/UDim2.md) value.

### ActivatedCursorIcon

```luau
UIDragDetector.ActivatedCursorIcon: string = ""
```

- Tags: Read capabilities: UI

Sets the cursor icon to display when the mouse is activated over the parent of this [`UIDragDetector`](https://rapi.sleaze.dev/classes/UIDragDetector.md).

### ActivatedCursorIconContent

```luau
UIDragDetector.ActivatedCursorIconContent: Content
```

- Tags: Read capabilities: UI

Sets the cursor icon to display when the mouse is activated over the parent of this [`UIDragDetector`](https://rapi.sleaze.dev/classes/UIDragDetector.md). Only supports asset URIs

### CursorIcon

```luau
UIDragDetector.CursorIcon: string = ""
```

- Tags: Read capabilities: UI

Sets the cursor icon to display when the mouse is hovered over the parent of this [`UIDragDetector`](https://rapi.sleaze.dev/classes/UIDragDetector.md).

### CursorIconContent

```luau
UIDragDetector.CursorIconContent: Content
```

- Tags: Read capabilities: UI

Sets the cursor icon to display when the mouse is hovered over the parent of this [`UIDragDetector`](https://rapi.sleaze.dev/classes/UIDragDetector.md). Only asset URIs are supported.

## Methods

### AddConstraintFunction

```luau
UIDragDetector:AddConstraintFunction(priority: number, function: (...any) -> ...any): RBXScriptConnection
```

- Tags: Capabilities: UI

Adds a function to modify or constrain proposed motion.

Parameters:

- `priority`: The order of priority for functions added via this method. Higher values take precedence over lower values.
- `function`: Function for modifying or constraining proposed motion. This function takes in input [`UDim2`](https://rapi.sleaze.dev/index/types/UDim2.md) and float of **proposed** motion and returns a [`UDim2`](https://rapi.sleaze.dev/index/types/UDim2.md) and float of **modified** or unmodified motion. It can optionally return an `UIDragDetectorDragRelativity` and `UIDragDetectorDragSpace` as the third and fourth return values as output overrides.

Returns: Use this connection object to remove the constraint function.

### GetReferencePosition

```luau
UIDragDetector:GetReferencePosition(): UDim2
```

- Tags: Capabilities: UI

Returns the reference [`UDim2`](https://rapi.sleaze.dev/index/types/UDim2.md) position of the current drag's reference origin.

Returns: [`UDim2`](https://rapi.sleaze.dev/index/types/UDim2.md) position of the current drag's reference element.

### GetReferenceRotation

```luau
UIDragDetector:GetReferenceRotation(): number
```

- Tags: Capabilities: UI

Returns the reference rotation of the current drag's reference element.

Returns: Rotation of the current drag's reference element.

### SetDragStyleFunction

```luau
UIDragDetector:SetDragStyleFunction(function: (...any) -> ...any)
```

- Tags: Capabilities: UI

Passes a function to be used if and only if [`DragStyle`](https://rapi.sleaze.dev/classes/UIDragDetector.md) is set to `UIDragDetectorDragStyle.Scriptable`.

Parameters:

- `function`: Function for monitoring [`DragContinue`](https://rapi.sleaze.dev/classes/UIDragDetector.md) signals. This function receives the signal's screen space input position and returns a [`UDim2`](https://rapi.sleaze.dev/index/types/UDim2.md) and float containing the desired motion of the drag in the desired space and relativity. If this function returns `nil`, the object will not be moved.

## Events

### DragContinue

```luau
UIDragDetector.DragContinue: RBXScriptSignal<(inputPosition: Vector2)>
```

- Tags: Capabilities: UI

Fires when a user continues dragging the UI element after [`DragStart`](https://rapi.sleaze.dev/classes/UIDragDetector.md) has been initiated.

### DragEnd

```luau
UIDragDetector.DragEnd: RBXScriptSignal<(inputPosition: Vector2)>
```

- Tags: Capabilities: UI

Fires when a user stops dragging the UI element.

### DragStart

```luau
UIDragDetector.DragStart: RBXScriptSignal<(inputPosition: Vector2)>
```

- Tags: Capabilities: UI

Fires when a user starts dragging the UI element.

## Inherited members

- From [Instance](https://rapi.sleaze.dev/classes/Instance.md): `Archivable`, `archivable`, `Attributes`, `AttributesReplicate`, `AttributesSerialize`, `HistoryId`, `Name`, `Parent`, `PredictionMode`, `PropertyStatusStudio`, `RobloxLocked`, `SerializedOverrides`, `SourceAssetId`, `Tags`, `UniqueId`, `numExpectedDirectChildren`, `DataCost`, `Capabilities`, `DefinesCapabilities`, `IsInSandbox`, `Sandboxed`, `AddTag`, `ClearAllChildren`, `Clone`, `Destroy`, `FindFirstAncestor`, `FindFirstAncestorOfClass`, `FindFirstAncestorWhichIsA`, `FindFirstChild`, `FindFirstChildOfClass`, `FindFirstChildWhichIsA`, `FindFirstDescendant`, `GetActor`, `GetAttribute`, `GetAttributeChangedSignal`, `GetAttributes`, `GetChildren`, `GetDebugId`, `GetDescendants`, `GetFullName`, `GetStyled`, `GetStyledPropertyChangedSignal`, `GetTags`, `HasTag`, `IsAncestorOf`, `IsDescendantOf`, `IsPropertyModified`, `QueryDescendants`, `RemoveTag`, `ResetPropertyToDefault`, `SetAttribute`, `WaitForChild`, `Remove`, `children`, `clone`, `destroy`, `findFirstChild`, `getChildren`, `isDescendantOf`, `remove`, `AncestryChanged`, `AttributeChanged`, `ChildAdded`, `ChildRemoved`, `DescendantAdded`, `DescendantRemoving`, `Destroying`, `StyledPropertiesChanged`, `childAdded`
- From [Object](https://rapi.sleaze.dev/classes/Object.md): `ClassName`, `className`, `GetPropertyChangedSignal`, `IsA`, `isA`, `Changed`
