Skip to main content

Event

Struct Event 

Source
pub struct Event<'alloc> { /* private fields */ }
Expand description

Keyboard input event containing information about the physical key pressed, modifiers, and generated text.

Implementations§

Source§

impl<'alloc> Event<'alloc>

Source

pub fn new() -> Result<Self>

Create a new key event instance.

Source

pub fn new_with_alloc<'ctx: 'alloc, Ctx>( alloc: &'alloc Allocator<'ctx, Ctx>, ) -> Result<Self>

Create a new key event instance with a custom allocator.

See the crate-level documentation regarding custom memory management and lifetimes.

Source

pub fn set_action(&mut self, action: Action) -> &mut Self

Set the key action (press, release, repeat).

Source

pub fn action(&self) -> Action

Get the key action (press, release, repeat).

Source

pub fn set_key(&mut self, key: Key) -> &mut Self

Set the physical key code.

Source

pub fn key(&self) -> Key

Get the physical key code.

Source

pub fn set_mods(&mut self, mods: Mods) -> &mut Self

Set the modifier keys bitmask.

Source

pub fn mods(&self) -> Mods

Get the modifier keys bitmask.

Source

pub fn set_consumed_mods(&mut self, mods: Mods) -> &mut Self

Set the consumed modifiers bitmask.

Source

pub fn consumed_mods(&self) -> Mods

Get the consumed modifiers bitmask.

Source

pub fn set_composing(&mut self, composing: bool) -> &mut Self

Set whether the key event is part of a composition sequence.

Source

pub fn is_composing(&self) -> bool

Get whether the key event is part of a composition sequence.

Source

pub fn set_utf8<S: Into<String>>(&mut self, text: Option<S>) -> &mut Self

Set the UTF-8 text generated by the key event.

The event makes an internal copy of the text since the C API may reuse it without any rigid lifetime guarantees.

Source

pub fn utf8(&mut self) -> Option<&str>

Get the UTF-8 text generated by the key event.

Source

pub fn set_unshifted_codepoint(&mut self, codepoint: char) -> &mut Self

Set the unshifted Unicode codepoint.

Source

pub fn unshifted_codepoint(&self) -> char

Get the unshifted Unicode codepoint.

Trait Implementations§

Source§

impl<'alloc> Debug for Event<'alloc>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Drop for Event<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'alloc> Freeze for Event<'alloc>

§

impl<'alloc> RefUnwindSafe for Event<'alloc>

§

impl<'alloc> !Send for Event<'alloc>

§

impl<'alloc> !Sync for Event<'alloc>

§

impl<'alloc> Unpin for Event<'alloc>

§

impl<'alloc> UnsafeUnpin for Event<'alloc>

§

impl<'alloc> UnwindSafe for Event<'alloc>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.