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>
impl<'alloc> Event<'alloc>
Sourcepub fn new_with_alloc<'ctx: 'alloc>(
alloc: &'alloc Allocator<'ctx>,
) -> Result<Self>
pub fn new_with_alloc<'ctx: 'alloc>( alloc: &'alloc Allocator<'ctx>, ) -> Result<Self>
Create a new key event instance with a custom allocator.
See the crate-level documentation regarding custom memory management and lifetimes.
Sourcepub fn set_action(&mut self, action: Action) -> &mut Self
pub fn set_action(&mut self, action: Action) -> &mut Self
Set the key action (press, release, repeat).
Sourcepub fn set_consumed_mods(&mut self, mods: Mods) -> &mut Self
pub fn set_consumed_mods(&mut self, mods: Mods) -> &mut Self
Set the consumed modifiers bitmask.
Sourcepub fn consumed_mods(&self) -> Mods
pub fn consumed_mods(&self) -> Mods
Get the consumed modifiers bitmask.
Sourcepub fn set_composing(&mut self, composing: bool) -> &mut Self
pub fn set_composing(&mut self, composing: bool) -> &mut Self
Set whether the key event is part of a composition sequence.
Sourcepub fn is_composing(&self) -> bool
pub fn is_composing(&self) -> bool
Get whether the key event is part of a composition sequence.
Sourcepub fn set_utf8<S: Into<String>>(&mut self, text: Option<S>) -> &mut Self
pub fn set_utf8<S: Into<String>>(&mut self, text: Option<S>) -> &mut Self
Set the UTF-8 text generated by the key for the current keyboard layout.
Must contain the unmodified character before any Ctrl/Meta transformations. The encoder derives modifier sequences from the logical key and mods bitmask, not from this text. Do not pass C0 control characters (U+0000-U+001F, U+007F) or platform function key codes (e.g. macOS PUA U+F700-U+F8FF); pass NULL instead and let the encoder use the logical key.
The event makes an internal copy of the text since the C API may reuse it without any rigid lifetime guarantees.
Sourcepub fn set_unshifted_codepoint(&mut self, codepoint: char) -> &mut Self
pub fn set_unshifted_codepoint(&mut self, codepoint: char) -> &mut Self
Set the unshifted Unicode codepoint.
Sourcepub fn unshifted_codepoint(&self) -> char
pub fn unshifted_codepoint(&self) -> char
Get the unshifted Unicode codepoint.