1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use glib::translate::*;
#[derive(Clone, Debug)]
pub struct EventKey(::Event);
event_wrapper!(EventKey, GdkEventKey);
event_subtype!(EventKey, KeyPress | KeyRelease);
impl EventKey {
pub fn get_time(&self) -> u32 {
self.as_ref().time
}
pub fn get_state(&self) -> ::ModifierType {
from_glib(self.as_ref().state)
}
pub fn get_keyval(&self) -> ::enums::key::Key {
self.as_ref().keyval as ::enums::key::Key
}
pub fn get_length(&self) -> u32 {
let length = self.as_ref().length;
assert!(length >= 0, "Unexpected negative value");
length as u32
}
pub fn get_hardware_keycode(&self) -> u16 {
self.as_ref().hardware_keycode
}
pub fn get_group(&self) -> u8 {
self.as_ref().group
}
}