pub enum PlatformKeymap {
LinuxWindows,
MacOs,
}Expand description
Platform-specific primary modifier (Ctrl vs Cmd).
§Examples
use ailloli_ui_text::PlatformKeymap;
assert_ne!(PlatformKeymap::LinuxWindows, PlatformKeymap::MacOs);Variants§
LinuxWindows
Treat Control as the primary shortcut modifier.
MacOs
Treat Meta/Command as the primary shortcut modifier.
Implementations§
Source§impl PlatformKeymap
impl PlatformKeymap
Sourcepub fn current() -> Self
pub fn current() -> Self
Returns the compile-target platform mapping.
macOS targets select Self::MacOs; every other target, including
Linux, Windows, and WebAssembly, selects Self::LinuxWindows. This is
compile-time selection, not runtime operating-system detection.
§Examples
use ailloli_ui_text::PlatformKeymap;
let current = PlatformKeymap::current();
assert!(matches!(current, PlatformKeymap::LinuxWindows | PlatformKeymap::MacOs));Sourcepub fn is_primary(self, event: &KeyEvent) -> bool
pub fn is_primary(self, event: &KeyEvent) -> bool
Tests only the platform’s primary modifier on a key event.
Other modifiers and the key state do not affect the result.
§Examples
use ailloli_ui_core::event::{Key, KeyEvent, KeyState, Modifiers};
use ailloli_ui_text::PlatformKeymap;
let event = KeyEvent {
state: KeyState::Pressed,
key: Key::Character("c".into()),
modifiers: Modifiers { ctrl: true, ..Modifiers::default() },
repeat: false,
pointer_pos: None,
text: None,
};
assert!(PlatformKeymap::LinuxWindows.is_primary(&event));
assert!(!PlatformKeymap::MacOs.is_primary(&event));Trait Implementations§
Source§impl Clone for PlatformKeymap
impl Clone for PlatformKeymap
Source§fn clone(&self) -> PlatformKeymap
fn clone(&self) -> PlatformKeymap
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PlatformKeymap
impl Debug for PlatformKeymap
Source§impl PartialEq for PlatformKeymap
impl PartialEq for PlatformKeymap
impl Copy for PlatformKeymap
impl Eq for PlatformKeymap
impl StructuralPartialEq for PlatformKeymap
Auto Trait Implementations§
impl Freeze for PlatformKeymap
impl RefUnwindSafe for PlatformKeymap
impl Send for PlatformKeymap
impl Sync for PlatformKeymap
impl Unpin for PlatformKeymap
impl UnwindSafe for PlatformKeymap
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.