Pointer Events
A pointer is a device-independent representation of input devices (such as a mouse, pen,or point of contact on a touch surface). A pointer can point to a specific coordinate(or set of coordinates) on a contact surface such as a screen.
All pointers can generate several kinds of events
Event | Constant | Description |
---|---|---|
"pointer-down" | PointerDown | The pointer was pressed. |
"pointer-up" | PointerUp | The pointer was released. |
"pointer-move" | PointerMove | The pointer has been moved |
"pointer-cancel" | PointerCancel | Pointer events aborted. |
"pointer-out" | PointerOut | The pointer went out of bounds of the View, or went into the child View |
"pointer-over" | PointerOver | The pointer is within the limits of View |
The main event data listener has the following format:
func(View, PointerEvent) where the second argument describes the parameters of the pointer. PointerEvent structure extends MouseEvent structureand has the following additional fields:
Field | Type | Description |
---|---|---|
PointerID | int | The unique identifier of the pointer that raised the event. |
Width | float64 | The width (X-axis value) in pixels of the pointer's contact geometry. |
Height | float64 | The height (Y-axis value) in pixels of the pointer's contact geometry. |
Pressure | float64 | Normalized gauge inlet pressure ranging from 0 to 1, where 0 and 1 represent the minimum and maximum pressure that the hardware is capable of detecting, respectively. |
TangentialPressure | float64 | Normalized gauge inlet tangential pressure (also known as cylinder pressure or cylinder voltage) ranges from -1 to 1, where 0 is the neutral position of the control. |
TiltX | float64 | The planar angle (in degrees, ranging from -90 to 90) between the Y – Z plane and the plane that contains both the pointer (such as a stylus) axis and the Y axis. |
TiltY | float64 | The planar angle (in degrees, ranging from -90 to 90) between the X – Z plane and the plane containing both the pointer (such as a stylus) axis and the X axis. |
Twist | float64 | Rotation of a pointer (for example, a stylus) clockwise around its main axis in degrees with a value in the range from 0 to 359. |
PointerType | string | the type of device that triggered the event: "mouse", "pen", "touch", etc. |
IsPrimary | bool | a pointer is the primary pointer of this type. |
You can also use listeners in the following formats:
- func(PointerEvent)
- func(View)
- func()
You can get lists of pointer event listeners using the functions:
func GetPointerDownListeners(view View, subviewID ...string) []func(View, PointerEvent) func GetPointerUpListeners(view View, subviewID ...string) []func(View, PointerEvent) func GetPointerMoveListeners(view View, subviewID ...string) []func(View, PointerEvent) func GetPointerCancelListeners(view View, subviewID ...string) []func(View, PointerEvent) func GetPointerOverListeners(view View, subviewID ...string) []func(View, PointerEvent) func GetPointerOutListeners(view View, subviewID ...string) []func(View, PointerEvent)