[][src]Struct genie_hki::Hotkey

pub struct Hotkey {
    pub key: i32,
    pub string_id: i32,
    pub ctrl: bool,
    pub alt: bool,
    pub shift: bool,
    // some fields omitted
}

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]

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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.