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: u32What the platform reports when it fires
(crate::EventKind::KeyCommand’s payload).
keystroke: KeystrokeThe keystroke.
in_text: boolIt fires while a text input or hosted native view has the keyboard
focus (When, resolved).
repeat: boolIt fires again on the auto-repeats of a held key; else once until the key is released.
pass_through: boolIt 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: boolIt 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: OverFocusedWhat it takes from the control with the keyboard focus
(OverFocused).
Implementations§
Source§impl KeyBinding
impl KeyBinding
Sourcepub fn new(
id: u32,
keystroke: Keystroke,
when: When,
repeat: bool,
) -> KeyBinding
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.
Sourcepub fn in_window(self, window: NodeId) -> KeyBinding
pub fn in_window(self, window: NodeId) -> KeyBinding
The binding firing only in the window of root node window
(Self::window).
Sourcepub fn passing_through(self, pass_through: bool) -> KeyBinding
pub fn passing_through(self, pass_through: bool) -> KeyBinding
The binding firing without consuming the key when pass_through
(Self::pass_through).
Sourcepub fn focus_keys(self, for_focus: bool) -> KeyBinding
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).
Sourcepub fn over_focused(self, over: impl Into<OverFocused>) -> KeyBinding
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).