Crate event_types

Source
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;
pub use keyboard_types;

Modules§

coordinate_space
Coordinate space marker structs
event_data
Collection of types describing data associated with some common input events

Structs§

Coordinates
Coordinates of a point in a user interface
KeyProperties
Describes a key’s values, typically at the time of a key event
PointerId
A unique identifier for a pointer causing an event.
PointerOrientation
The orientation (tilt or spherical angles, and twist) of a transducer (e.g. pen/stylus)
PointerProperties
Describes a pointer’s values, typically at the time of a pointer event

Enums§

PointerButton
A pointer button type (such as Primary/Secondary)
PointerType
Device type associated with an event
WheelDelta
A vector representing the movement of the mouse wheel

Type Aliases§

ClientPoint
A point in ClientSpace
ElementPoint
A point in ElementSpace
LinesVector
A vector expressed in Lines
PagePoint
A point in PageSpace
PagesVector
A vector expressed in Pages
PixelsVector
A vector expressed in Pixels
PointerButtonSet
A set of pointer buttons
ScreenPoint
A point in ScreenSpace