Skip to main content

KeyBinding

Struct KeyBinding 

Source
pub struct KeyBinding {
    pub id: u32,
    pub keystroke: Keystroke,
    pub in_text: bool,
    pub repeat: bool,
    pub pass_through: bool,
    pub window: Option<NodeId>,
    pub for_focus: bool,
    pub over_focused: OverFocused,
}
Expand description

One binding of a Keymap.

Fields§

§id: u32

What the platform reports when it fires (crate::EventKind::KeyCommand’s payload).

§keystroke: Keystroke

The keystroke.

§in_text: bool

It fires while a text input or hosted native view has the keyboard focus (When, resolved).

§repeat: bool

It fires again on the auto-repeats of a held key; else once until the key is released.

§pass_through: bool

It fires and lets the key go on as if there were no binding (KeyMatch::Notify): Tab still moves the focus, a text input still types. Else the platform consumes the key.

§window: Option<NodeId>

The window it belongs to, as its root node (a dialog root for a window of the app’s own): it fires only for keys pressed there. None: in any window. crate::ROOT_ID is the app root, which is app-wide in window model v2 (it is not a user window).

§for_focus: bool

It is the keys of the view with the keyboard focus (a component’s, bound while its part has the focus or its popup is open): Return and Space reach it while the focus is on a control they press (Keymap::find_at). Other bindings of those keys give way to the focused control.

§over_focused: OverFocused

What it takes from the control with the keyboard focus (OverFocused).

Implementations§

Source§

impl KeyBinding

Source

pub fn new( id: u32, keystroke: Keystroke, when: When, repeat: bool, ) -> KeyBinding

A binding of keystroke firing as when says, on auto-repeats too when repeat.

Source

pub fn in_window(self, window: NodeId) -> KeyBinding

The binding firing only in the window of root node window (Self::window).

Source

pub fn passing_through(self, pass_through: bool) -> KeyBinding

The binding firing without consuming the key when pass_through (Self::pass_through).

Source

pub fn focus_keys(self, for_focus: bool) -> KeyBinding

The binding being the keys of the view with the keyboard focus when for_focus (Self::for_focus).

Source

pub fn over_focused(self, over: impl Into<OverFocused>) -> KeyBinding

The binding taking from the control with the keyboard focus what over says (Self::over_focused; true is OverFocused::Always, false OverFocused::Never).

Trait Implementations§

Source§

impl Clone for KeyBinding

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 Copy for KeyBinding

Source§

impl Debug for KeyBinding

Source§

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

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

impl Eq for KeyBinding

Source§

impl PartialEq for KeyBinding

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 KeyBinding

Auto Trait Implementations§

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.