Pointer Events

enum PuglScrollDirection

Scroll direction.

Describes the direction of a PuglScrollEvent along with whether the scroll is a “smooth” scroll. The discrete directions are for devices like mouse wheels with constrained axes, while a smooth scroll is for those with arbitrary scroll direction freedom, like some touchpads.

enumerator PUGL_SCROLL_UP

Scroll up.

enumerator PUGL_SCROLL_DOWN

Scroll down.

enumerator PUGL_SCROLL_LEFT

Scroll left.

enumerator PUGL_SCROLL_RIGHT

Scroll right.

enumerator PUGL_SCROLL_SMOOTH

Smooth scroll in any direction.

struct PuglButtonEvent

Button press or release event.

Button numbers start from 0, and are ordered: primary, secondary, middle. So, on a typical right-handed mouse, the button numbers are:

Left: 0 Right: 1 Middle (often a wheel): 2

Higher button numbers are reported in the same order they are represented on the system. There is no universal standard here, but buttons 3 and 4 are typically a pair of buttons or a rocker, which are usually bound to “back” and “forward” operations.

Note that these numbers may differ from those used on the underlying platform, since they are manipulated to provide a consistent portable API.

PuglEventType type

PuglEventType.PUGL_BUTTON_PRESS or PuglEventType.PUGL_BUTTON_RELEASE

PuglEventFlags flags

Bitwise OR of PuglEventFlag values.

double time

Time in seconds.

double x

View-relative X coordinate.

double y

View-relative Y coordinate.

double xRoot

Root-relative X coordinate.

double yRoot

Root-relative Y coordinate.

PuglMods state

Bitwise OR of PuglMod flags.

uint32_t button

Button number starting from 0.

struct PuglCrossingEvent

Pointer enter or leave event.

This is sent when the pointer enters or leaves the view. This can happen for several reasons (not just the user dragging the pointer over the window edge), as described by the mode field.

PuglEventType type

PuglEventType.PUGL_POINTER_IN or PuglEventType.PUGL_POINTER_OUT

PuglEventFlags flags

Bitwise OR of PuglEventFlag values.

double time

Time in seconds.

double x

View-relative X coordinate.

double y

View-relative Y coordinate.

double xRoot

Root-relative X coordinate.

double yRoot

Root-relative Y coordinate.

PuglMods state

Bitwise OR of PuglMod flags.

PuglCrossingMode mode

Reason for crossing.

struct PuglMotionEvent

Pointer motion event.

PuglEventType type

PuglEventType.PUGL_MOTION

PuglEventFlags flags

Bitwise OR of PuglEventFlag values.

double time

Time in seconds.

double x

View-relative X coordinate.

double y

View-relative Y coordinate.

double xRoot

Root-relative X coordinate.

double yRoot

Root-relative Y coordinate.

PuglMods state

Bitwise OR of PuglMod flags.

struct PuglScrollEvent

Scroll event.

The scroll distance is expressed in “lines”, an arbitrary unit that corresponds to a single tick of a detented mouse wheel. For example, dy = 1.0 scrolls 1 line up. Some systems and devices support finer resolution and/or higher values for fast scrolls, so programs should handle any value gracefully.

PuglEventType type

PuglEventType.PUGL_SCROLL

PuglEventFlags flags

Bitwise OR of PuglEventFlag values.

double time

Time in seconds.

double x

View-relative X coordinate.

double y

View-relative Y coordinate.

double xRoot

Root-relative X coordinate.

double yRoot

Root-relative Y coordinate.

PuglMods state

Bitwise OR of PuglMod flags.

PuglScrollDirection direction

Scroll direction.

double dx

Scroll X distance in lines.

double dy

Scroll Y distance in lines.