pub enum Event {
    MousePress {
        button: MouseButton,
        position: (f64, f64),
        modifiers: Modifiers,
        handled: bool,
    },
    MouseRelease {
        button: MouseButton,
        position: (f64, f64),
        modifiers: Modifiers,
        handled: bool,
    },
    MouseMotion {
        button: Option<MouseButton>,
        delta: (f64, f64),
        position: (f64, f64),
        modifiers: Modifiers,
        handled: bool,
    },
    MouseWheel {
        delta: (f64, f64),
        position: (f64, f64),
        modifiers: Modifiers,
        handled: bool,
    },
    MouseEnter,
    MouseLeave,
    KeyPress {
        kind: Key,
        modifiers: Modifiers,
        handled: bool,
    },
    KeyRelease {
        kind: Key,
        modifiers: Modifiers,
        handled: bool,
    },
    ModifiersChange {
        modifiers: Modifiers,
    },
    Text(String),
}
Expand description

An input event (from mouse, keyboard or similar).

Variants§

§

MousePress

Fields

§button: MouseButton

Type of button

§position: (f64, f64)

The screen position in logical pixels, to get it in physical pixels, multiply it with the device pixel ratio. The first value defines the position on the horizontal axis with zero being at the left border of the window and the second on the vertical axis with zero being at the top edge of the window.

§modifiers: Modifiers

The state of modifiers.

§handled: bool

Whether or not this event already have been handled.

Fired when a button is pressed or the screen is touched.

§

MouseRelease

Fields

§button: MouseButton

Type of button

§position: (f64, f64)

The screen position in logical pixels, to get it in physical pixels, multiply it with the device pixel ratio. The first value defines the position on the horizontal axis with zero being at the left border of the window and the second on the vertical axis with zero being at the top edge of the window.

§modifiers: Modifiers

The state of modifiers.

§handled: bool

Whether or not this event already have been handled.

Fired when a button is released or the screen is stopped being touched.

§

MouseMotion

Fields

§button: Option<MouseButton>

Type of button if a button is pressed.

§delta: (f64, f64)

The relative movement of the mouse/finger since last Event::MouseMotion event.

§position: (f64, f64)

The screen position in logical pixels, to get it in physical pixels, multiply it with the device pixel ratio. The first value defines the position on the horizontal axis with zero being at the left border of the window and the second on the vertical axis with zero being at the top edge of the window.

§modifiers: Modifiers

The state of modifiers.

§handled: bool

Whether or not this event already have been handled.

Fired continuously when the mouse or a finger on the screen is moved.

§

MouseWheel

Fields

§delta: (f64, f64)

The relative scrolling since the last Event::MouseWheel event.

§position: (f64, f64)

The screen position in logical pixels, to get it in physical pixels, multiply it with the device pixel ratio. The first value defines the position on the horizontal axis with zero being at the left border of the window and the second on the vertical axis with zero being at the top edge of the window.

§modifiers: Modifiers

The state of modifiers.

§handled: bool

Whether or not this event already have been handled.

Fired continuously when the mouse wheel or equivalent is applied.

§

MouseEnter

Fired when the mouse enters the window.

§

MouseLeave

Fired when the mouse leaves the window.

§

KeyPress

Fields

§kind: Key

The type of key.

§modifiers: Modifiers

The state of modifiers.

§handled: bool

Whether or not this event already have been handled.

Fired when a key is pressed.

§

KeyRelease

Fields

§kind: Key

The type of key.

§modifiers: Modifiers

The state of modifiers.

§handled: bool

Whether or not this event already have been handled.

Fired when a key is released.

§

ModifiersChange

Fields

§modifiers: Modifiers

The state of modifiers after the change.

Fired when the modifiers change.

§

Text(String)

Fires when some text has been written.

Trait Implementations§

source§

impl Clone for Event

source§

fn clone(&self) -> Event

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Event

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl RefUnwindSafe for Event

§

impl Send for Event

§

impl Sync for Event

§

impl Unpin for Event

§

impl UnwindSafe for Event

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> SerializableAny for Twhere T: 'static + Any + Clone + Send + Sync,