PointerInput Class

A pointer of an input device of the user (https://w3c.github.io/pointerevents/#dfn-pointer): the mouse, a pen, or a finger on a touch screen. See UserInput.

public sealed class PointerInput

Properties

NameDescription
ButtonsGets the pressed buttons (https://w3c.github.io/pointerevents/#dfn-chorded-button-interactions: the buttons bit mask). A touch pointer in contact presses the primary button.
IsPrimaryGets a value indicating whether the pointer is the primary pointer of its type (https://w3c.github.io/pointerevents/#dfn-primary-pointer).
PointerIdGets the identifier of the pointer (https://w3c.github.io/pointerevents/#dom-pointerevent-pointerid): 1 for the mouse; a touch pointer gets a new identifier for each contact, and a pen when it is first used.
PointerTypeGets the type of the device: mouse, pen or touch.
XGets the horizontal position of the pointer in the viewport of the top-level browsing context.
YGets the vertical position of the pointer in the viewport of the top-level browsing context.

Gets the pressed buttons (https://w3c.github.io/pointerevents/#dfn-chorded-button-interactions: the buttons bit mask). A touch pointer in contact presses the primary button.

public int Buttons { get; }

Property value

int

IsPrimary

UserInput.cs

Gets a value indicating whether the pointer is the primary pointer of its type (https://w3c.github.io/pointerevents/#dfn-primary-pointer).

public bool IsPrimary { get; }

Property value

bool

PointerId

UserInput.cs

Gets the identifier of the pointer (https://w3c.github.io/pointerevents/#dom-pointerevent-pointerid): 1 for the mouse; a touch pointer gets a new identifier for each contact, and a pen when it is first used.

public int PointerId { get; }

Property value

int

PointerType

UserInput.cs

Gets the type of the device: mouse, pen or touch.

public string PointerType { get; }

Property value

string

Gets the horizontal position of the pointer in the viewport of the top-level browsing context.

public double X { get; }

Property value

double

Gets the vertical position of the pointer in the viewport of the top-level browsing context.

public double Y { get; }

Property value

double

Methods

NameDescription
BeginDrag(DragData)Starts a drag from outside the page at the position of the mouse, as when the user drags files from the file manager into the window: dragenter and dragover are fired at the element under the pointer. Then PointerInput.Move fires the drag events (not the pointer events), PointerInput.Up drops the data, and Escape (KeyboardInput.Press) or PointerInput.Cancel cancels the drag.
Cancel()Cancels the pointer (https://w3c.github.io/pointerevents/#dfn-pointercancel-event): pointercancel, and the buttons are released without click.
Down(int, PointerInputProperties?)Presses a button of the pointer (0: primary, 1: auxiliary, 2: secondary), or starts the contact of a touch pointer.
Move(double, double, PointerInputProperties?)Moves the pointer to a position of the viewport of the top-level browsing context: the boundary events, then pointermove and its compatibility mouse event; a touch pointer in contact may pan (scroll) instead, as touch-action allows. While the mouse is locked (https://w3c.github.io/pointerlock/), it keeps its position (PointerInput.X, PointerInput.Y): the events are fired at the pointer-lock target with the movement from the position of the previous move (movementX, movementY); see PointerInput.MoveBy.
MoveBy(double, double, PointerInputProperties?)Moves the pointer by a distance, as PointerInput.Move does: the movement of the device that a host reads while the mouse is locked, where the pointer has no position.
Up(int)Releases a button of the pointer, or ends the contact of a touch pointer: pointerup, then the click events.

BeginDrag(DragData)

UserInput.cs

Starts a drag from outside the page at the position of the mouse, as when the user drags files from the file manager into the window: dragenter and dragover are fired at the element under the pointer. Then PointerInput.Move fires the drag events (not the pointer events), PointerInput.Up drops the data, and Escape (KeyboardInput.Press) or PointerInput.Cancel cancels the drag.

public void BeginDrag(DragData data)

Parameters

data DragData
The files, the directories and the strings that are dragged.

Exceptions

InvalidOperationException
The pointer is not the mouse, or a button is pressed.

Cancel()

UserInput.cs

Cancels the pointer (https://w3c.github.io/pointerevents/#dfn-pointercancel-event): pointercancel, and the buttons are released without click.

public void Cancel()

Down(int, PointerInputProperties?)

UserInput.cs

Presses a button of the pointer (0: primary, 1: auxiliary, 2: secondary), or starts the contact of a touch pointer.

public void Down(int button = 0, PointerInputProperties? properties = null)

Parameters

button int
properties PointerInputProperties?

Move(double, double, PointerInputProperties?)

UserInput.cs

Moves the pointer to a position of the viewport of the top-level browsing context: the boundary events, then pointermove and its compatibility mouse event; a touch pointer in contact may pan (scroll) instead, as touch-action allows. While the mouse is locked (https://w3c.github.io/pointerlock/), it keeps its position (PointerInput.X, PointerInput.Y): the events are fired at the pointer-lock target with the movement from the position of the previous move (movementX, movementY); see PointerInput.MoveBy.

public void Move(double x, double y, PointerInputProperties? properties = null)

Parameters

x double
y double
properties PointerInputProperties?

MoveBy(double, double, PointerInputProperties?)

UserInput.cs

Moves the pointer by a distance, as PointerInput.Move does: the movement of the device that a host reads while the mouse is locked, where the pointer has no position.

public void MoveBy(double deltaX, double deltaY, PointerInputProperties? properties = null)

Parameters

deltaX double
deltaY double
properties PointerInputProperties?

Releases a button of the pointer, or ends the contact of a touch pointer: pointerup, then the click events.

public void Up(int button = 0)

Parameters

button int