aboutsummaryrefslogtreecommitdiffstats
path: root/examples/grabbing.rs
diff options
context:
space:
mode:
authortomaka <pierre.krieger1708@gmail.com>2015-03-28 11:24:18 +0100
committertomaka <pierre.krieger1708@gmail.com>2015-03-28 11:24:18 +0100
commit125ebed031e4c660ffbece8aeb03938044ec7a96 (patch)
tree821ed56e144076363da249a23f94c92eaabe71a4 /examples/grabbing.rs
parentd6ebaaaf5cbb1839e74c3c7c0573b1f842c59e6b (diff)
parentb27306f97221bb7db52775321abbe3daa0ae9ccb (diff)
downloadglutin-125ebed031e4c660ffbece8aeb03938044ec7a96.tar.gz
glutin-125ebed031e4c660ffbece8aeb03938044ec7a96.zip
Merge pull request #333 from tomaka/fix
Change grab_cursor and ungrab_cursor to set_cursor_state
Diffstat (limited to 'examples/grabbing.rs')
-rw-r--r--examples/grabbing.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/examples/grabbing.rs b/examples/grabbing.rs
index 436dd9b..07e3873 100644
--- a/examples/grabbing.rs
+++ b/examples/grabbing.rs
@@ -1,3 +1,5 @@
+#![feature(std_misc)]
+
#[cfg(target_os = "android")]
#[macro_use]
extern crate android_glue;
@@ -16,7 +18,6 @@ fn main() { println!("This example requires glutin to be compiled with the `wind
#[cfg(feature = "window")]
fn main() {
-
let window = glutin::Window::new().unwrap();
window.set_title("glutin - Cursor grabbing test");
unsafe { window.make_current() };
@@ -33,11 +34,12 @@ fn main() {
Event::KeyboardInput(ElementState::Pressed, _, _) => {
if grabbed {
grabbed = false;
- window.ungrab_cursor();
- }
- else {
+ window.set_cursor_state(glutin::CursorState::Normal)
+ .ok().expect("could not ungrab mouse cursor");
+ } else {
grabbed = true;
- window.grab_cursor().ok().expect("could not grab mouse cursor");
+ window.set_cursor_state(glutin::CursorState::Grab)
+ .ok().expect("could not grab mouse cursor");
}
},
_ => (),