Class Draggable
Manipulator which monitors Press, Hold and Release events in order to drag visuals.
Implements
Inherited Members
Namespace: Unity.AppUI.UI
Assembly: Unity.AppUI.dll
Syntax
public class Draggable : Pressable, IManipulator
Constructors
Draggable(Action, Action<Draggable>, Action<Draggable>, Action<Draggable>)
Construct a Draggable manipulator.
Declaration
public Draggable(Action clickHandler, Action<Draggable> dragHandler, Action<Draggable> upHandler, Action<Draggable> downHandler = null)
Parameters
Type | Name | Description |
---|---|---|
Action | clickHandler | A callback invoked when a Click |
Action<Draggable> | dragHandler | A callback invoked during dragging state. |
Action<Draggable> | upHandler | A callback invoked when a Pointer |
Action<Draggable> | downHandler | A callback invoked when a Pointer |
Properties
acceptDrag
Accept the drag operation.
Declaration
public Func<Draggable, bool> acceptDrag { get; set; }
Property Value
actionKey
Whether the Action Key is currently pressed (Cmd on macOS, Ctrl on Windows).
Declaration
public bool actionKey { get; }
Property Value
Type | Description |
---|---|
bool |
altKey
Whether the Alt Key is currently pressed.
Declaration
public bool altKey { get; }
Property Value
Type | Description |
---|---|
bool |
ctrlKey
Whether the Ctrl Key is currently pressed.
Declaration
public bool ctrlKey { get; }
Property Value
Type | Description |
---|---|
bool |
deltaPos
The delta position between the last frame and the current one.
Declaration
public Vector2 deltaPos { get; }
Property Value
Type | Description |
---|---|
Vector2 |
deltaStartPos
The delta position between the start of the drag and the current frame.
Declaration
public Vector2 deltaStartPos { get; }
Property Value
Type | Description |
---|---|
Vector2 |
dragDirection
The direction of the drag.
Declaration
public Draggable.DragDirection dragDirection { get; set; }
Property Value
Type | Description |
---|---|
Draggable.Drag |
hasMoved
Has the pointer moved since the last Pointer
Declaration
public bool hasMoved { get; }
Property Value
Type | Description |
---|---|
bool |
isDown
Whether the pointer is currently down.
Declaration
public bool isDown { get; }
Property Value
Type | Description |
---|---|
bool |
localPosition
The local position received from the imGui native event.
Declaration
public Vector2 localPosition { get; }
Property Value
Type | Description |
---|---|
Vector2 |
position
The world position received from the imGui native event.
Declaration
public Vector2 position { get; }
Property Value
Type | Description |
---|---|
Vector2 |
shiftKey
Whether the Shift Key is currently pressed.
Declaration
public bool shiftKey { get; }
Property Value
Type | Description |
---|---|
bool |
startPosition
The start position of the drag, based on the world position received from the imGui native event.
Declaration
public Vector2 startPosition { get; }
Property Value
Type | Description |
---|---|
Vector2 |
threshold
The threshold in pixels to start the drag operation.
Declaration
public float threshold { get; set; }
Property Value
Type | Description |
---|---|
float |
Methods
Cancel()
Cancel the drag operation.
Declaration
public void Cancel()
ProcessDownEvent(EventBase, Vector2, int)
This method processes the down event sent to the target Element.
Declaration
protected override void ProcessDownEvent(EventBase evt, Vector2 localPosition, int pointerId)
Parameters
Type | Name | Description |
---|---|---|
Event |
evt | The event to process. |
Vector2 | localPosition | The local position of the pointer. |
int | pointerId | The pointer id of the pointer. |
Overrides
ProcessMoveEvent(EventBase, Vector2)
This method processes the move event sent to the target Element.
Declaration
protected override void ProcessMoveEvent(EventBase evt, Vector2 localPosition)
Parameters
Type | Name | Description |
---|---|---|
Event |
evt | The event to process. |
Vector2 | localPosition | The local position of the pointer. |
Overrides
ProcessUpEvent(EventBase, Vector2, int)
This method processes the up event sent to the target Element.
Declaration
protected override void ProcessUpEvent(EventBase evt, Vector2 localPosition, int pointerId)
Parameters
Type | Name | Description |
---|---|---|
Event |
evt | The event to process. |
Vector2 | localPosition | The local position of the pointer. |
int | pointerId | The pointer id of the pointer. |