This repository has been archived by the owner on Jun 8, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Nicer bindings for Key(val) related functions
Fix #345
- Loading branch information
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
extern crate gdk; | ||
extern crate gdk_sys; | ||
|
||
use gdk::enums::key::Keys; | ||
|
||
#[test] | ||
fn check_event() { | ||
gdk::init(); | ||
let base_ev = gdk::Event::new(gdk::EventType::KeyPress); | ||
let mut ev: gdk::EventKey = base_ev.downcast().unwrap(); | ||
ev.as_mut().keyval = gdk::enums::key::A; | ||
|
||
let keyval = gdk::keyval_to_unicode(ev.get_keyval()); | ||
let keyval2 = ev.get_keyval().to_unicode(); | ||
|
||
assert_eq!(keyval, Some('A')); | ||
assert_eq!(keyval, keyval2); | ||
|
||
let name = gdk::keyval_name(ev.get_keyval()); | ||
let name2 = ev.get_keyval().name(); | ||
|
||
assert_eq!(name, Some("A".into())); | ||
assert_eq!(name, name2); | ||
} |