Expand description

Types to help idiomatically represent user input events, such as pointer clicks and moves.

use euclid::num::Zero;
use keyboard_types::Modifiers;
use event_types::event_data::PointerDown;
use event_types::*;

// Your library can construct event data
let pointer_data = PointerProperties::builder()
            .coordinates(Coordinates::zero())
            .held_buttons(PointerButton::Primary)
            .id(PointerId(0))
            .pointer_type(PointerType::Mouse)
            .is_primary(true)
            .build();
let event_data = PointerDown::new(pointer_data, Modifiers::SHIFT, PointerButton::Primary, 1);

// So that your users can get info about input events
dbg!(event_data.button_pressed());
dbg!(event_data.pointer());
dbg!(event_data.modifiers());

Overview

The rest are mostly small structs and enums helping describe event data and its units.

Usage

This library only provides types to represent data associated with input events. It does not provide an event system itself. Therefore, if you are writing a GUI framework, you will most likely have to bring:

  • Your own Event wrapper, which will contain:
    • Event data from structs in event_data (possibly in a Vec if you want to batch some events)
    • Some sort of reference to the target element
    • Facilities for default event behavior and cancelling it, if desired
    • Event bubbling and preventing it, if desired
  • Your own event data for events not in this crate (e.g. clipboard events)
  • Your own components and ways to attach event listeners to them

Re-exports

pub use enumset;
pub use euclid;

Modules

Coordinate space marker structs

Collection of types describing data associated with some common input events

Structs

Coordinates of a point in a user interface

Describes a key’s values, typically at the time of a key event

A unique identifier for a pointer causing an event.

The orientation (tilt or spherical angles, and twist) of a transducer (e.g. pen/stylus)

Describes a pointer’s values, typically at the time of a pointer event

Enums

A pointer button type (such as Primary/Secondary)

Device type associated with an event

A vector representing the movement of the mouse wheel

Type Definitions

A vector expressed in Lines

A point in PageSpace

A vector expressed in Pages

A vector expressed in Pixels

A set of pointer buttons