Class PointerEventBase<T>
This is the base class for pointer events.
Inherited Members
Namespace: UnityEngine.UIElements
Syntax
public abstract class PointerEventBase<T> : EventBase<T>, IPointerEvent, IPointerEventInternal where T : PointerEventBase<T>, new()
Type Parameters
Name | Description |
---|---|
T |
Remarks
Pointer events are sent by the mouse, touchscreen, or digital pens.
By default, pointer events trickle down the hierarchy of VisualElements, and then bubble up back to the root. They are cancellable at any stage of the propagation.
A cycle of pointer events occurs as follows:
- The user presses a mouse button, touches the screen, or otherwise causes a PointerDownEvent to be sent.
- If the user changes the pointer's state, a PointerMoveEvent is sent. Many PointerMove events can be sent.
- If the user doesn't change the pointer's state for a specific amount of time, a PointerStationaryEvent is sent.
- If the user cancels the loop, a PointerCancelEvent is sent.
- If the user doesn't cancel the loop, and either releases the last button pressed or releases the last touch, a PointerUpEvent is sent.
- If the initial PointerDownEvent and the PointerUpEvent occur on the same VisualElement, a ClickEvent is sent.
Constructors
PointerEventBase()
Declaration
protected PointerEventBase()
Properties
actionKey
Gets a boolean value that indicates whether the platform-specific action key is pressed. True means the action key is pressed. False means it isn't.
Declaration
public bool actionKey { get; }
Property Value
Type | Description |
---|---|
Boolean |
Implements
Remarks
The platform-specific action key is Cmd on macOS, and Ctrl on all other platforms.
altitudeAngle
Gets the angle of the stylus relative to the surface, in radians
Declaration
public float altitudeAngle { get; protected set; }
Property Value
Type | Description |
---|---|
Single |
Implements
Remarks
A value of 0 indicates that the stylus is parallel to the surface. A value of pi/2 indicates that it is perpendicular to the surface.
altKey
Gets a boolean value that indicates whether the Alt key is pressed. True means the Alt key is pressed. False means it isn't.
Declaration
public bool altKey { get; }
Property Value
Type | Description |
---|---|
Boolean |
Implements
azimuthAngle
Gets the angle of the stylus relative to the x-axis, in radians.
Declaration
public float azimuthAngle { get; protected set; }
Property Value
Type | Description |
---|---|
Single |
Implements
Remarks
A value of 0 indicates that the stylus is pointed along the x-axis of the device.
button
Gets a value that indicates which mouse button was pressed: 0 is the left button, 1 is the right button, 2 is the middle button.
Declaration
public int button { get; protected set; }
Property Value
Type | Description |
---|---|
Int32 |
Implements
clickCount
Gets the number of times the button was pressed.
Declaration
public int clickCount { get; protected set; }
Property Value
Type | Description |
---|---|
Int32 |
Implements
commandKey
Gets a boolean value that indicates whether the Windows/Cmd key is pressed. True means the Windows/Cmd key is pressed. False means it isn't.
Declaration
public bool commandKey { get; }
Property Value
Type | Description |
---|---|
Boolean |
Implements
ctrlKey
Gets a boolean value that indicates whether the Ctrl key is pressed. True means the Ctrl key is pressed. False means it isn't.
Declaration
public bool ctrlKey { get; }
Property Value
Type | Description |
---|---|
Boolean |
Implements
currentTarget
Gets the current target of the event.
Declaration
public override IEventHandler currentTarget { get; }
Property Value
Type | Description |
---|---|
IEventHandler |
Overrides
Remarks
The current target is the element in the propagation path for which event handlers are currently being executed.
deltaPosition
Gets the difference between the pointer's position during the previous mouse event and its position during the current mouse event.
Declaration
public Vector3 deltaPosition { get; protected set; }
Property Value
Type | Description |
---|---|
Vector3 |
Implements
deltaTime
Gets the amount of time that has elapsed since the last recorded change in pointer values, in seconds.
Declaration
public float deltaTime { get; protected set; }
Property Value
Type | Description |
---|---|
Single |
Implements
isPrimary
Gets a boolean value that indicates whether the pointer is a primary pointer. True means the pointer is a primary pointer. False means it isn't.
Declaration
public bool isPrimary { get; protected set; }
Property Value
Type | Description |
---|---|
Boolean |
Implements
Remarks
A primary pointer is a pointer that manipulates the mouse cursor. The mouse pointer is always a primary pointer. For touch events, the first finger that touches the screen is the primary pointer. Once it is processed, a pointer event from a primary pointer generates compatibility mouse events.
localPosition
Gets the pointer position in the current target's coordinate system.
Declaration
public Vector3 localPosition { get; protected set; }
Property Value
Type | Description |
---|---|
Vector3 |
Implements
modifiers
Gets flags that indicate whether modifier keys (Alt, Ctrl, Shift, Windows/Cmd) are pressed.
Declaration
public EventModifiers modifiers { get; protected set; }
Property Value
Type | Description |
---|---|
EventModifiers |
Implements
pointerId
Gets the identifier of the pointer that sent the event.
Declaration
public int pointerId { get; protected set; }
Property Value
Type | Description |
---|---|
Int32 |
Implements
Remarks
If the mouse sends the event, the identifier is set to 0. If a touchscreen device sends the event, the identifier is set to the finger ID, which ranges from 1 to the number of touches the device supports.
pointerType
Gets the type of pointer that created the event.
Declaration
public string pointerType { get; protected set; }
Property Value
Type | Description |
---|---|
String |
Implements
Remarks
This value is taken from the values defined in PointerType
.
position
Gets the pointer position in the Screen or World coordinate system.
Declaration
public Vector3 position { get; protected set; }
Property Value
Type | Description |
---|---|
Vector3 |
Implements
pressedButtons
Gets a bitmask that describes the buttons that are currently pressed.
Declaration
public int pressedButtons { get; protected set; }
Property Value
Type | Description |
---|---|
Int32 |
Implements
Remarks
Pressing a mouse button sets a bit. Releasing the button clears the bit. The left mouse button sets/clears Bit 0. The right mouse button sets/clears Bit 1. The middle mouse button sets/clears Bit 2. Additional buttons set/clear other bits.
pressure
Gets the amount of pressure currently applied by a touch.
Declaration
public float pressure { get; protected set; }
Property Value
Type | Description |
---|---|
Single |
Implements
Remarks
If the device does not report pressure, the value of this property is 1.0f.
radius
Gets an estimate of the radius of a touch.
Declaration
public Vector2 radius { get; protected set; }
Property Value
Type | Description |
---|---|
Vector2 |
Implements
Remarks
Add radiusVariance
to get the maximum touch radius, subtract it to get the minimum touch radius.
radiusVariance
Gets the accuracy of the touch radius.
Declaration
public Vector2 radiusVariance { get; protected set; }
Property Value
Type | Description |
---|---|
Vector2 |
Implements
Remarks
Add this value to the radius to get the maximum touch radius, subtract it to get the minimum touch radius.
shiftKey
Gets a boolean value that indicates whether the Shift key is pressed. True means the Shift key is pressed. False means it isn't.
Declaration
public bool shiftKey { get; }
Property Value
Type | Description |
---|---|
Boolean |
Implements
tangentialPressure
Gets the pressure applied to an additional pressure-sensitive control on the stylus.
Declaration
public float tangentialPressure { get; protected set; }
Property Value
Type | Description |
---|---|
Single |
Implements
twist
Gets the rotation of the stylus around its axis, in radians.
Declaration
public float twist { get; protected set; }
Property Value
Type | Description |
---|---|
Single |
Implements
Methods
GetPooled(Event)
Gets an event from the event pool and initializes it with the given values. Use this function instead of creating new events.
Events obtained using this method need to be released back to the pool. You can use Dispose()
to release them.
Declaration
public static T GetPooled(Event systemEvent)
Parameters
Type | Name | Description |
---|---|---|
Event | systemEvent | An IMGUI mouse event. |
Returns
Type | Description |
---|---|
T | An initialized event. |
GetPooled(Touch, EventModifiers)
Gets an event from the event pool and initializes it with the given values. Use this function instead of creating new events.
Events obtained using this method need to be released back to the pool. You can use Dispose()
to release them.
Declaration
public static T GetPooled(Touch touch, EventModifiers modifiers = null)
Parameters
Type | Name | Description |
---|---|---|
Touch | touch | A |
EventModifiers | modifiers | The modifier keys held down during the event. |
Returns
Type | Description |
---|---|
T | An initialized event. |
GetPooled(IPointerEvent)
Gets an event from the event pool and initializes it with the given values. Use this function instead of creating new events.
Events obtained using this method need to be released back to the pool. You can use Dispose()
to release them.
Declaration
public static T GetPooled(IPointerEvent triggerEvent)
Parameters
Type | Name | Description |
---|---|---|
IPointerEvent | triggerEvent | The event that sent this event. |
Returns
Type | Description |
---|---|
T | An initialized event. |
Init()
Resets the event members to their initial values.
Declaration
protected override void Init()
Overrides
PostDispatch(IPanel)
Declaration
protected override void PostDispatch(IPanel panel)
Parameters
Type | Name | Description |
---|---|---|
IPanel | panel |
Overrides
PreDispatch(IPanel)
Declaration
protected override void PreDispatch(IPanel panel)
Parameters
Type | Name | Description |
---|---|---|
IPanel | panel |