Struct zng_ext_input::keyboard::KeyInputArgs
source · pub struct KeyInputArgs {
pub timestamp: DInstant,
pub window_id: WindowId,
pub device_id: DeviceId,
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: DInstant
Instant the event happened.
window_id: WindowId
Window that received the event.
device_id: DeviceId
Device that generated the event.
key_code: KeyCode
Physical key.
key_location: KeyLocation
The location of the key on the keyboard.
state: KeyState
If the key was pressed or released.
key: Key
Semantic key.
Pressing Shift+A
key will produce Key::Char('a')
in QWERTY keyboards, the modifiers are not applied.
key_modified: Key
Semantic key modified by the current active modifiers.
Pressing Shift+A
key will produce Key::Char('A')
in QWERTY keyboards, the modifiers are applied.
text: Txt
Text 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: ModifiersState
What modifier keys where pressed when this event happened.
repeat_count: u32
Number 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: InteractionPath
The 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<DeviceId>,
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>,
) -> Self
pub fn new( timestamp: impl Into<DInstant>, propagation_handle: EventPropagationHandle, window_id: impl Into<WindowId>, device_id: impl Into<DeviceId>, 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>, ) -> Self
New args from values that convert into the argument types.
sourcepub fn now(
window_id: impl Into<WindowId>,
device_id: impl Into<DeviceId>,
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>,
) -> Self
pub fn now( window_id: impl Into<WindowId>, device_id: impl Into<DeviceId>, 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>, ) -> Self
Arguments for event that happened now (INSTANT.now
).
source§impl KeyInputArgs
impl KeyInputArgs
sourcepub fn is_enabled(&self, widget_id: WidgetId) -> bool
pub fn is_enabled(&self, widget_id: WidgetId) -> bool
Returns true
if the widget is enabled in target
.
sourcepub fn is_disabled(&self, widget_id: WidgetId) -> bool
pub fn is_disabled(&self, widget_id: WidgetId) -> bool
Returns true
if the widget is disabled in target
.
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.
source§impl KeyInputArgs
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,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§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> 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