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 event_data module: Collection of types describing some common input events
- KeyProperties: Describes a key
- PointerProperties: Describes a pointer
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
- Pointer
Id - A unique identifier for a pointer causing an event.
- Pointer
Orientation - The orientation (tilt or spherical angles, and twist) of a transducer (e.g. pen/stylus)
- Pointer
Properties - Describes a pointer’s values, typically at the time of a pointer event
Enums§
- Pointer
Button - A pointer button type (such as Primary/Secondary)
- Pointer
Type - Device type associated with an event
- Wheel
Delta - A vector representing the movement of the mouse wheel
Type Aliases§
- Client
Point - A point in ClientSpace
- Element
Point - A point in ElementSpace
- Lines
Vector - A vector expressed in Lines
- Page
Point - A point in PageSpace
- Pages
Vector - A vector expressed in Pages
- Pixels
Vector - A vector expressed in Pixels
- Pointer
Button Set - A set of pointer buttons
- Screen
Point - A point in ScreenSpace