pub struct KeyInputArgs {
pub timestamp: DInstant,
pub window_id: WindowId,
pub device_id: InputDeviceId,
pub key_code: KeyCode,
pub key_location: KeyLocation,
pub state: KeyState,
pub key: Key,
pub key_modified: Key,
pub text: Txt,
pub modifiers: ModifiersState,
pub repeat_count: u32,
pub target: InteractionPath,
/* private fields */
}Expand description
Arguments for KEY_INPUT_EVENT.
Fields§
§timestamp: DInstantInstant the event happened.
window_id: WindowIdWindow that received the event.
device_id: InputDeviceIdDevice that generated the event.
key_code: KeyCodePhysical key.
key_location: KeyLocationThe location of the key on the keyboard.
state: KeyStateIf the key was pressed or released.
key: KeySemantic key.
Pressing Shift+A key will produce Key::Char('a') in QWERTY keyboards, the modifiers are not applied.
key_modified: KeySemantic key modified by the current active modifiers.
Pressing Shift+A key will produce Key::Char('A') in QWERTY keyboards, the modifiers are applied.
text: TxtText typed.
This is only set during KeyState::Pressed of a key that generates text.
This is usually the key_modified char, but is also '\r' for Key::Enter. On Windows when a dead key was
pressed earlier but cannot be combined with the character from this key press, the produced text
will consist of two characters: the dead-key-character followed by the character resulting from this key press.
modifiers: ModifiersStateWhat modifier keys where pressed when this event happened.
repeat_count: u32Number of repeats generated by holding the key pressed.
This is zero for the first key press, increments by one for each event while the key is held pressed.
target: InteractionPathThe focused element at the time of the key input.
Implementations§
Source§impl KeyInputArgs
impl KeyInputArgs
Sourcepub fn new(
timestamp: impl Into<DInstant>,
propagation_handle: EventPropagationHandle,
window_id: impl Into<WindowId>,
device_id: impl Into<InputDeviceId>,
key_code: impl Into<KeyCode>,
key_location: impl Into<KeyLocation>,
state: impl Into<KeyState>,
key: impl Into<Key>,
key_modified: impl Into<Key>,
text: impl Into<Txt>,
modifiers: impl Into<ModifiersState>,
repeat_count: impl Into<u32>,
target: impl Into<InteractionPath>,
) -> KeyInputArgs
pub fn new( timestamp: impl Into<DInstant>, propagation_handle: EventPropagationHandle, window_id: impl Into<WindowId>, device_id: impl Into<InputDeviceId>, key_code: impl Into<KeyCode>, key_location: impl Into<KeyLocation>, state: impl Into<KeyState>, key: impl Into<Key>, key_modified: impl Into<Key>, text: impl Into<Txt>, modifiers: impl Into<ModifiersState>, repeat_count: impl Into<u32>, target: impl Into<InteractionPath>, ) -> KeyInputArgs
New args from values that convert into the argument types.
Sourcepub fn now(
window_id: impl Into<WindowId>,
device_id: impl Into<InputDeviceId>,
key_code: impl Into<KeyCode>,
key_location: impl Into<KeyLocation>,
state: impl Into<KeyState>,
key: impl Into<Key>,
key_modified: impl Into<Key>,
text: impl Into<Txt>,
modifiers: impl Into<ModifiersState>,
repeat_count: impl Into<u32>,
target: impl Into<InteractionPath>,
) -> KeyInputArgs
pub fn now( window_id: impl Into<WindowId>, device_id: impl Into<InputDeviceId>, key_code: impl Into<KeyCode>, key_location: impl Into<KeyLocation>, state: impl Into<KeyState>, key: impl Into<Key>, key_modified: impl Into<Key>, text: impl Into<Txt>, modifiers: impl Into<ModifiersState>, repeat_count: impl Into<u32>, target: impl Into<InteractionPath>, ) -> KeyInputArgs
Arguments for event that happened now (INSTANT.now).
Source§impl KeyInputArgs
Shortcut methods.
impl KeyInputArgs
Shortcut methods.
Sourcepub fn shortcut_key(&self) -> &Key
pub fn shortcut_key(&self) -> &Key
Gets the modified key for Numpad keys and the unmodified key for the rest.
Sourcepub fn editing_shortcut(&self) -> Option<Shortcut>
pub fn editing_shortcut(&self) -> Option<Shortcut>
Gets the best shortcut approximation of the current pressed state.
Note that the returned shortcut may be invalid, don’t use this to match shortcut presses, use
the GESTURES service for that. This method is for key binding editors.
This helper also does not support chords, only single key and modifier gestures.
Returns None if this event if for a key release.
Source§impl KeyInputArgs
Text input methods.
impl KeyInputArgs
Text input methods.
The text field contains the raw text associated with the key-press by the operating system,
these methods normalize and filter this text.
Sourcepub fn is_backspace(&self) -> bool
pub fn is_backspace(&self) -> bool
Returns true if the character is the backspace and CTRL is not pressed.
Sourcepub fn is_delete(&self) -> bool
pub fn is_delete(&self) -> bool
Returns true if the character is delete and CTRL is not pressed.
Sourcepub fn is_tab(&self) -> bool
pub fn is_tab(&self) -> bool
Returns true if the character is a tab space and CTRL is not pressed.
Sourcepub fn is_line_break(&self) -> bool
pub fn is_line_break(&self) -> bool
Returns true if the character is a line-break and CTRL is not pressed.
Sourcepub fn insert_str(&self) -> &str
pub fn insert_str(&self) -> &str
Gets the characters to insert in a typed text.
Replaces all is_tab with \t and all is_line_break with \n.
Returns "" if there is no text or it contains ASCII control characters or CTRL is pressed.
Trait Implementations§
Source§impl AnyEventArgs for KeyInputArgs
impl AnyEventArgs for KeyInputArgs
Source§fn delivery_list(&self, list: &mut UpdateDeliveryList)
fn delivery_list(&self, list: &mut UpdateDeliveryList)
The target.
Source§fn clone_any(&self) -> Box<dyn AnyEventArgs>
fn clone_any(&self) -> Box<dyn AnyEventArgs>
Source§fn propagation(&self) -> &EventPropagationHandle
fn propagation(&self) -> &EventPropagationHandle
Source§impl Clone for KeyInputArgs
impl Clone for KeyInputArgs
Source§fn clone(&self) -> KeyInputArgs
fn clone(&self) -> KeyInputArgs
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for KeyInputArgs
impl Debug for KeyInputArgs
Auto Trait Implementations§
impl Freeze for KeyInputArgs
impl RefUnwindSafe for KeyInputArgs
impl Send for KeyInputArgs
impl Sync for KeyInputArgs
impl Unpin for KeyInputArgs
impl UnwindSafe for KeyInputArgs
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> FsChangeNote for T
impl<T> FsChangeNote for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more