Skip to main content

Keymap

Struct Keymap 

Source
pub struct Keymap { /* private fields */ }
Expand description

The bindings of a surface, oldest first.

Implementations§

Source§

impl Keymap

Source

pub fn new(bindings: Vec<KeyBinding>) -> Keymap

A table of bindings, oldest first.

Source

pub fn gives_way( &self, binding: &KeyBinding, eligible: impl Fn(&KeyBinding) -> bool, ) -> bool

Whether binding gives way while the keyboard focus is on a control its key presses (Return, Space; crate::input::presses_focused_control). The focus’ own bindings (KeyBinding::for_focus) take such a key, the others give way to the control. When a pointer gave the focus (Keymap::pointer_focus) and an eligible binding of the key takes it over such a focus (OverFocused::Pointer), only those take it: the focus’ own give way to them too (a Select trigger’s Space opening its list). A platform that matches keys itself (GTK’s shortcuts) passes the bindings eligible in the current window and focus.

Source

pub fn is_empty(&self) -> bool

No bindings: the platform need not look at keys.

Source

pub fn bindings(&self) -> &[KeyBinding]

The bindings, oldest first.

Source

pub fn find( &self, keystroke: Keystroke, editing: bool, repeat: bool, ) -> KeyMatch

What a key does: the newest binding of keystroke that fires while editing (a text input or hosted native view has the keyboard focus) takes it; repeat is an auto-repeat of a held key, which only fires bindings that ask for it. A binding that passes the key through gives KeyMatch::Notify, and its held key’s auto-repeats go on (KeyMatch::None) unless it repeats. The key is pressed with the app root as the window (Self::find_in).

Source

pub fn find_in( &self, window: NodeId, keystroke: Keystroke, editing: bool, repeat: bool, ) -> KeyMatch

Self::find for a key pressed in the window of root node window: only that window’s bindings and those of no window (KeyBinding::window) take it.

Source

pub fn find_at( &self, window: NodeId, keystroke: Keystroke, editing: bool, control: bool, repeat: bool, ) -> KeyMatch

Self::find_in where the keyboard focus may be on a control (control: a view that takes presses, not a text input). The keys that press it (crate::input::presses_focused_control: Return and Space) are its own: only the bindings of the focus (KeyBinding::for_focus, a menu button’s Return opening its menu) take them first; with none, the key goes on and the platform presses the control. A binding of Return elsewhere (a dialog’s main action) does not act instead of the control the user moved the focus to; one that takes them over a pointer’s focus (OverFocused::Pointer) does when a pointer gave it (Keymap::pointer_focus).

Source

pub fn find_with( &self, window: NodeId, keystroke: Keystroke, focus: KeyFocus, repeat: bool, ) -> KeyMatch

Self::find_at with where the keyboard focus is as one value. A focus the newest modal over its window covers (KeyFocus::covered) has no keys of its own: the bindings of the focus (KeyBinding::for_focus, a menu button’s Return opening its menu under a dialog) do not take the key, so the dialog’s do.

Trait Implementations§

Source§

impl Clone for Keymap

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Keymap

Source§

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

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

impl Default for Keymap

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for Keymap

Source§

impl PartialEq for Keymap

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Keymap

Auto Trait Implementations§

§

impl Forget for Keymap

§

impl Freeze for Keymap

§

impl Move for Keymap

§

impl RefUnwindSafe for Keymap

§

impl Send for Keymap
where RawVecInner: Send,

§

impl Sync for Keymap
where RawVecInner: Sync,

§

impl Unpin for Keymap
where *const u8 is !null: Unpin,

§

impl UnsafeUnpin for Keymap

§

impl UnwindSafe for Keymap
where RawVecInner: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.