HoverPointer

A pointer is a position on the screen chosen by the user using a mouse, touchpad, touchscreen or other device capable of communicating some position.

While in a typical desktop application there will usually be a single pointer at a time, there can be cases where there may be none (no mouse connected) or more (multitouch-enabled screen, multiple mouses connected, etc.)

A pointer is associated with an I/O system that represents the device that invoked the pointer. This may be a dedicated mouse node, but it may also be a generic system that abstracts the device away; for example, Raylib provides a singular function for getting the mouse position without distinguishing between multiple devices or touchscreens.

For a pointer to work, it has to be loaded into a HoverIO system using its load method. This has to be done once a frame for as long as the pointer is active. This will be every frame for a mouse (if one is connected), or only the frames a finger is touching the screen for a touchscreen.

Members

Functions

emitEvent
void emitEvent(InputEvent event)

Emit an event through the pointer.

id
int id()
isSame
bool isSame(HoverPointer other)

Test if the two pointers have the same origin — same device and pointer number.

load
void load(HoverIO hoverIO, int id)

Load the pointer into the system.

loadCopy
inout(HoverPointer) loadCopy(HoverIO hoverIO, int id)
Undocumented in source. Be warned that the author may not have intended to support it.
opEquals
bool opEquals(HoverPointer other)

Compare two pointers. All publicly exposed fields (device, number, position, isDisabled) must be equal. To check if the two pointers have the same origin (device and number), use isSame.

system
inout(HoverIO) system()
update
void update(HoverPointer other)

Update a pointer in place using data of another pointer.

Static functions

fetch
Optional!HoverPointer fetch(IO io, int number)

If the given system is a Hover I/O system, fetch a hover pointer.

Variables

clickCount
int clickCount;

Consecutive click counter. A value of 1 represents a single click, 2 is a double click, 3 is a triple click, and so on. The counter should reset after a small delay, or if a distance threshold is crossed.

device
IO device;

I/O system that represents the device controlling the pointer.

isDisabled
bool isDisabled;

True if the pointer is not currently pointing, like a finger that stopped touching the screen.

isScrollHeld
bool isScrollHeld;

If true, the scroll control is held, like a finger swiping through the screen. This does not apply to mouse wheels.

number
int number;

If the device can control multiple pointers (like a touchscreen), this number should uniquely identify a pointer.

position
Vector2 position;

Position in the window the pointer is pointing at.

scroll
Vector2 scroll;

Current scroll value. For a mouse, this indicates mouse wheel movement, for other devices like touchpad or touchscreen, this will be translated from its movement.

See Also

HoverIO, HoverIO.load

Meta