Class Clickable
Manipulator that tracks Mouse events on an element and callbacks when the elements is clicked.
Inherited Members
Namespace: UnityEngine.UIElements
Syntax
public class Clickable : PointerManipulator, IManipulator
Constructors
Clickable(System.Action)
Constructor.
Declaration
public Clickable(System.Action handler)
Parameters
Type | Name | Description |
---|---|---|
System.Action | handler |
Clickable(System.Action, Int64, Int64)
Constructor.
Declaration
public Clickable(System.Action handler, long delay, long interval)
Parameters
Type | Name | Description |
---|---|---|
System.Action | handler | |
Int64 | delay | Determines when the event begins. Applies if delay > 0. |
Int64 | interval | Determines the time delta between event repetition. Applies if interval > 0. |
Clickable(System.Action<EventBase>)
Constructor.
Declaration
public Clickable(System.Action<EventBase> handler)
Parameters
Type | Name | Description |
---|---|---|
System.Action<EventBase> | handler |
Properties
active
This property tracks the activation of the manipulator. Set it to true when the manipulator is activated.
Declaration
protected bool active { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
lastMousePosition
Specifies the mouse position saved during the last mouse event on the target Element.
Declaration
public Vector2 lastMousePosition { get; }
Property Value
Type | Description |
---|---|
Vector2 |
Methods
Invoke(EventBase)
Invokes a click action.
Declaration
protected void Invoke(EventBase evt)
Parameters
Type | Name | Description |
---|---|---|
EventBase | evt |
OnMouseDown(MouseDownEvent)
This method is called when a MouseDownEvent is sent to the target element.
Declaration
protected void OnMouseDown(MouseDownEvent evt)
Parameters
Type | Name | Description |
---|---|---|
MouseDownEvent | evt | The event. |
OnMouseMove(MouseMoveEvent)
This method is called when a MouseMoveEvent is sent to the target element.
Declaration
protected void OnMouseMove(MouseMoveEvent evt)
Parameters
Type | Name | Description |
---|---|---|
MouseMoveEvent | evt | The event. |
OnMouseUp(MouseUpEvent)
This method is called when a MouseUpEvent is sent to the target element.
Declaration
protected void OnMouseUp(MouseUpEvent evt)
Parameters
Type | Name | Description |
---|---|---|
MouseUpEvent | evt | The event. |
ProcessCancelEvent(EventBase, Int32)
This method processes the up cancel sent to the target Element.
Declaration
protected virtual void ProcessCancelEvent(EventBase evt, int pointerId)
Parameters
Type | Name | Description |
---|---|---|
EventBase | evt | |
Int32 | pointerId |
ProcessDownEvent(EventBase, Vector2, Int32)
This method processes the down event sent to the target Element.
Declaration
protected virtual void ProcessDownEvent(EventBase evt, Vector2 localPosition, int pointerId)
Parameters
Type | Name | Description |
---|---|---|
EventBase | evt | |
Vector2 | localPosition | |
Int32 | pointerId |
ProcessMoveEvent(EventBase, Vector2)
This method processes the move event sent to the target Element.
Declaration
protected virtual void ProcessMoveEvent(EventBase evt, Vector2 localPosition)
Parameters
Type | Name | Description |
---|---|---|
EventBase | evt | |
Vector2 | localPosition |
ProcessUpEvent(EventBase, Vector2, Int32)
This method processes the up event sent to the target Element.
Declaration
protected virtual void ProcessUpEvent(EventBase evt, Vector2 localPosition, int pointerId)
Parameters
Type | Name | Description |
---|---|---|
EventBase | evt | |
Vector2 | localPosition | |
Int32 | pointerId |
RegisterCallbacksOnTarget()
Called to register mouse event callbacks on the target element.
Declaration
protected override void RegisterCallbacksOnTarget()
Overrides
UnregisterCallbacksFromTarget()
Called to unregister event callbacks from the target element.
Declaration
protected override void UnregisterCallbacksFromTarget()
Overrides
Events
clicked
Callback triggered when the target element is clicked.
Declaration
public event System.Action clicked
Event Type
Type | Description |
---|---|
System.Action |
clickedWithEventInfo
Callback triggered when the target element is clicked, including event data.
Declaration
public event System.Action<EventBase> clickedWithEventInfo
Event Type
Type | Description |
---|---|
System.Action<EventBase> |