pub struct KeyboardShortcut {
pub modifiers: Modifiers,
pub logical_key: Key,
}Available on crate feature
egui only.Expand description
A keyboard shortcut, e.g. Ctrl+Alt+W.
Can be used with crate::InputState::consume_shortcut
and crate::Context::format_shortcut.
Fields§
§modifiers: Modifiers§logical_key: KeyImplementations§
Source§impl KeyboardShortcut
impl KeyboardShortcut
pub const fn new(modifiers: Modifiers, logical_key: Key) -> KeyboardShortcut
pub fn format(&self, names: &ModifierNames<'_>, is_mac: bool) -> String
Sourcepub fn conflicts_with_text_editing(&self) -> bool
pub fn conflicts_with_text_editing(&self) -> bool
Would consuming this shortcut interfere with editing text (e.g. moving the text cursor, or typing a space)?
This is true for any shortcut without modifiers (e.g. Space, A, Delete),
as well as for shortcuts using keys that are commonly combined with modifiers
when editing text (e.g. Alt+ArrowLeft to move one word, or Shift+Home to select to the start of a line).
Such shortcuts should only be consumed when no text field has keyboard focus.
See also crate::Memory::focused and crate::Context::egui_wants_keyboard_input.
assert!(KeyboardShortcut::new(Modifiers::NONE, Key::Space).conflicts_with_text_editing());
assert!(KeyboardShortcut::new(Modifiers::ALT, Key::ArrowLeft).conflicts_with_text_editing());
assert!(!KeyboardShortcut::new(Modifiers::COMMAND, Key::S).conflicts_with_text_editing());Trait Implementations§
Source§impl Clone for KeyboardShortcut
impl Clone for KeyboardShortcut
Source§fn clone(&self) -> KeyboardShortcut
fn clone(&self) -> KeyboardShortcut
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for KeyboardShortcut
Source§impl Debug for KeyboardShortcut
impl Debug for KeyboardShortcut
impl Eq for KeyboardShortcut
Source§impl Hash for KeyboardShortcut
impl Hash for KeyboardShortcut
Source§impl PartialEq for KeyboardShortcut
impl PartialEq for KeyboardShortcut
impl StructuralPartialEq for KeyboardShortcut
Auto Trait Implementations§
impl Forget for KeyboardShortcut
impl Freeze for KeyboardShortcut
impl Move for KeyboardShortcut
impl RefUnwindSafe for KeyboardShortcut
impl Send for KeyboardShortcut
impl Sync for KeyboardShortcut
impl Unpin for KeyboardShortcut
impl UnsafeUnpin for KeyboardShortcut
impl UnwindSafe for KeyboardShortcut
Blanket Implementations§
impl<T> AsId for T
impl<T> AsIdSalt for T
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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> ⓘ
Converts
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> ⓘ
Converts
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