Class MouseEventBase<T>
The base class for mouse events.
Inherited Members
Namespace: UnityEngine.UIElements
Syntax
public abstract class MouseEventBase<T> : EventBase<T>, IMouseEvent, IMouseEventInternal where T : MouseEventBase<T>, new()
Type Parameters
Name | Description |
---|---|
T |
Constructors
MouseEventBase()
Declaration
protected MouseEventBase()
Properties
actionKey
Returns true if the platform-specific action key is pressed. This key is Cmd on macOS, and Ctrl on all other platforms.
Declaration
public bool actionKey { get; }
Property Value
Type | Description |
---|---|
Boolean |
Implements
altKey
Returns true if the Alt key is pressed.
Declaration
public bool altKey { get; }
Property Value
Type | Description |
---|---|
Boolean |
Implements
button
Integer that indicates which mouse button is 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
The number of times the button is pressed.
Declaration
public int clickCount { get; protected set; }
Property Value
Type | Description |
---|---|
Int32 |
Implements
commandKey
Returns true if the Windows/Cmd key is pressed.
Declaration
public bool commandKey { get; }
Property Value
Type | Description |
---|---|
Boolean |
Implements
ctrlKey
Returns true if the Ctrl key is pressed.
Declaration
public bool ctrlKey { get; }
Property Value
Type | Description |
---|---|
Boolean |
Implements
currentTarget
The current target of the event. The current target is the element in the propagation path for which event handlers are currently being executed.
Declaration
public override IEventHandler currentTarget { get; }
Property Value
Type | Description |
---|---|
IEventHandler |
Overrides
localMousePosition
The mouse position in the current target coordinate system.
Declaration
public Vector2 localMousePosition { get; }
Property Value
Type | Description |
---|---|
Vector2 |
Implements
modifiers
Flags that hold pressed modifier keys (Alt, Ctrl, Shift, Windows/Cmd).
Declaration
public EventModifiers modifiers { get; protected set; }
Property Value
Type | Description |
---|---|
EventModifiers |
Implements
mouseDelta
The difference of the mouse position between the previous mouse event and the current mouse event.
Declaration
public Vector2 mouseDelta { get; protected set; }
Property Value
Type | Description |
---|---|
Vector2 |
Implements
mousePosition
The mouse position in the screen coordinate system.
Declaration
public Vector2 mousePosition { get; protected set; }
Property Value
Type | Description |
---|---|
Vector2 |
Implements
pressedButtons
A bitmask that describes the currently pressed buttons.
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 it. 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.
shiftKey
Returns true if the Shift key is pressed.
Declaration
public bool shiftKey { get; }
Property Value
Type | Description |
---|---|
Boolean |
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(IMouseEvent)
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(IMouseEvent triggerEvent)
Parameters
Type | Name | Description |
---|---|---|
IMouseEvent | triggerEvent | The event that sent this 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
protected static T GetPooled(IPointerEvent pointerEvent)
Parameters
Type | Name | Description |
---|---|---|
IPointerEvent | pointerEvent | The pointer event that sent this event. |
Returns
Type | Description |
---|---|
T | An initialized event. |
GetPooled(Vector2, Int32, Int32, Vector2, 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(Vector2 position, int button, int clickCount, Vector2 delta, EventModifiers modifiers = null)
Parameters
Type | Name | Description |
---|---|---|
Vector2 | position | The mouse position. |
Int32 | button | The mouse button pressed. |
Int32 | clickCount | The number of consecutive mouse clicks received. |
Vector2 | delta | The relative movement of the mouse compared to the mouse position when the last event was received. |
EventModifiers | modifiers | The modifier keys held down during the 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 |