[−][src]Struct genie_hki::Hotkey
The information about a single hotkey.
Fields
key: i32
Keycode that activates this hotkey.
You can use a crate like keycodes
to compare this to named virtual keys like keycodes::KEY_RETURN
.
If string_id
is -1
, this key
must be 0
.
string_id: i32
The string ID for this hotkey's label. -1 if this hotkey is unused.
ctrl: bool
Whether the Ctrl key needs to be held to activate this hotkey.
alt: bool
Whether the Alt key needs to be held to activate this hotkey.
shift: bool
Whether the Shift key needs to be held to activate this hotkey.
Implementations
impl Hotkey
[src]
pub fn key(self, key: i32) -> Self
[src]
Returns a hotkey equivalent to this one but with the key set to key
.
Examples
use genie_hki::Hotkey; let hki = Hotkey::default(); let hki2 = hki.key(5); assert_eq!(0, hki.key); assert_eq!(5, hki2.key);
pub fn string_id(self, string_id: i32) -> Self
[src]
Returns a hotkey equivalent to this one but with the string key set
to string_id
.
If the id is -1
, the returned key also has a key
field set to 0
.
Examples
use genie_hki::Hotkey; let hki = Hotkey::default(); let hki2 = hki.string_id(5); assert_eq!(-1, hki.string_id); assert_eq!(5, hki2.string_id); let hki3 = hki2.key(5); let hki4 = hki3.string_id(-1); assert_eq!(5, hki3.key); assert_eq!(0, hki4.key);
pub fn ctrl(self, ctrl: bool) -> Self
[src]
Returns a hotkey equivalent to this one but with ctrl
determining
whether control must be held when pressing the key.
Examples
use genie_hki::Hotkey; let hki = Hotkey::default(); let hki2 = hki.ctrl(true); assert!(!hki.ctrl); assert!(hki2.ctrl);
pub fn alt(self, alt: bool) -> Self
[src]
Returns a hotkey equivalent to this one but with alt
determining
whether alt must be held when pressing the key.
Examples
use genie_hki::Hotkey; let hki = Hotkey::default(); let hki2 = hki.alt(true); assert!(!hki.alt); assert!(hki2.alt);
pub fn shift(self, shift: bool) -> Self
[src]
Returns a hotkey equivalent to this one but with shift
determining
whether shift must be held when pressing the key.
Examples
use genie_hki::Hotkey; let hki = Hotkey::default(); let hki2 = hki.shift(true); assert!(!hki.shift); assert!(hki2.shift);
pub fn to_string_lang(&self, lang_file: &LangFile) -> String
[src]
Returns a string representation of this hotkey, using the strings from
lang_file
.
Examples
use genie_hki::Hotkey; use genie_lang::{LangFile, StringKey}; let mut lang_file = LangFile::new(); lang_file.insert(StringKey::from(5u32), String::from("A")); let hotkey = Hotkey::default().key(65).string_id(5).ctrl(true); assert_eq!("A (5): ctrl-65", hotkey.to_string_lang(&lang_file)); let default = Hotkey::default(); assert_eq!("-1: 0", default.to_string_lang(&lang_file));
Trait Implementations
impl Clone for Hotkey
[src]
impl Copy for Hotkey
[src]
impl Debug for Hotkey
[src]
impl Default for Hotkey
[src]
impl Display for Hotkey
[src]
impl Eq for Hotkey
[src]
impl Hash for Hotkey
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl PartialEq<Hotkey> for Hotkey
[src]
impl StructuralEq for Hotkey
[src]
impl StructuralPartialEq for Hotkey
[src]
Auto Trait Implementations
impl RefUnwindSafe for Hotkey
impl Send for Hotkey
impl Sync for Hotkey
impl Unpin for Hotkey
impl UnwindSafe for Hotkey
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,