pub struct KeyBinder<T> { /* private fields */ }Expand description
§Main Keybinder struct
This struct is a safe wrapper for KeyBinder and contains functions to initialize KeyBinder, bind keys and then unbind keys.
The struct guarantees that keybinder_init is called only once. This means
you can use this struct anywhere inside your code. Only the first time you call
KeyBinder::new() will call keybinder_init.
§Note
Make sure you initialize GTK before initializing KeyBinder
Example:
use keybinder::KeyBinder;
fn main() {
gtk::init().expect("Failed to init GTK");
let data = String::from("some data");
let mut keybinder = KeyBinder::<String>::new(true).expect("Keybinder is not supported");
assert_eq!(keybinder.bind("<Shift>space", |key, data| {
println!("key: {} , data: {}", key, data);
gtk::main_quit();
}, data), true);
println!("Successfully bound keystring to handler");
gtk::main();
}Implementations§
Source§impl<T> KeyBinder<T>
impl<T> KeyBinder<T>
Sourcepub fn new(use_cooked: bool) -> Result<Self, ()>
pub fn new(use_cooked: bool) -> Result<Self, ()>
Creates and initializes Keybinder(It it’s not already initialized).
§Returns
Ok(Self) if KeyBinder is supported. Otherwise, Err(()).
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for KeyBinder<T>
impl<T> RefUnwindSafe for KeyBinder<T>where
T: RefUnwindSafe,
impl<T> !Send for KeyBinder<T>
impl<T> !Sync for KeyBinder<T>
impl<T> Unpin for KeyBinder<T>where
T: Unpin,
impl<T> UnsafeUnpin for KeyBinder<T>
impl<T> UnwindSafe for KeyBinder<T>where
T: UnwindSafe,
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