pub struct KeyboardState {
pub enabled: bool,
pub text_input_focused: bool,
pub slide: Tween,
pub current_layer: Layer,
pub last_painted_keys: Vec<PaintedKey>,
pub last_panel_height: Option<f64>,
pub pressed_key_index: Option<usize>,
pub captured_pointer: bool,
pub caps_lock: bool,
pub last_shift_tap: Option<Instant>,
pub key_repeat: Option<KeyRepeatState>,
pub dismiss_requested: bool,
}Expand description
All mutable state owned by the keyboard module.
Kept private to the module so callers can’t accidentally diverge from
the controlled-mutation rules (e.g. retargeting the tween also
requires request_draw to wake the event loop).
Fields§
§enabled: boolHost opted in via super::set_enabled. Defaults to false so
desktop apps that never call it see no keyboard.
text_input_focused: boolSet by super::set_text_input_focused when the focused widget
reports accepts_text_input.
slide: TweenSlide animation. Value in [0.0, 1.0] interprets as
“fraction of the keyboard panel visible from the bottom”.
current_layer: LayerActive layer (lowercase letters / shifted letters / numbers / symbols).
last_painted_keys: Vec<PaintedKey>Painted keys from the most recent paint pass. Used for tap hit-testing. Coordinates are in the same Y-up viewport space the paint pass uses.
last_panel_height: Option<f64>Height of the most recently painted panel in logical pixels.
None until first paint. Used by super::occluded_height to
report how much screen real estate the keyboard is consuming.
pressed_key_index: Option<usize>Index into last_painted_keys of the key currently held down,
if any. Cleared when the pointer is released or moves off the
panel.
captured_pointer: booltrue between MouseDown and MouseUp on the panel — used by
the move/up handlers to know they should keep consuming events.
caps_lock: booltrue if the user has toggled caps lock on (via double-tap
shift). Holds the keyboard in the Shifted layer until shift
is tapped again.
last_shift_tap: Option<Instant>Most recent shift-key tap, used to detect double-tap → caps lock. Cleared after a non-shift key press or after the double-tap window expires.
key_repeat: Option<KeyRepeatState>State machine for the held key (currently only Backspace). When
set we keep firing the key every repeat_period after an
initial delay, until the pointer releases / leaves.
dismiss_requested: boolSet by super::dismiss when the user taps the keyboard’s
close key. Drained once per event-loop iteration by the App
(see App::drain_keyboard_events), which calls
set_focus(None) so the previously-focused text field gets a
FocusLost and the keyboard-aware lift retargets back to 0 —
otherwise the keyboard panel slides down but the tree stays
lifted, leaving an empty band where the keyboard used to be.
Implementations§
Source§impl KeyboardState
impl KeyboardState
Sourcepub fn visible_fraction(&self) -> f64
pub fn visible_fraction(&self) -> f64
Current eased visible fraction. Wraps Tween::value so callers
outside the module don’t need a mutable borrow just to peek.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for KeyboardState
impl RefUnwindSafe for KeyboardState
impl Send for KeyboardState
impl Sync for KeyboardState
impl Unpin for KeyboardState
impl UnsafeUnpin for KeyboardState
impl UnwindSafe for KeyboardState
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§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>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§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>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§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.Source§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.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().