2016-03-27 04:07:52 +11:00
|
|
|
extern crate winit;
|
2015-01-13 11:22:37 +11:00
|
|
|
|
2017-06-08 00:12:41 +10:00
|
|
|
use winit::{Event, ElementState, MouseCursor, WindowEvent, KeyboardInput, ControlFlow};
|
2015-01-13 11:22:37 +11:00
|
|
|
|
2015-12-27 01:38:00 +11:00
|
|
|
fn main() {
|
2017-06-08 00:12:41 +10:00
|
|
|
let mut events_loop = winit::EventsLoop::new();
|
2017-01-29 01:45:01 +11:00
|
|
|
|
|
|
|
let window = winit::WindowBuilder::new().build(&events_loop).unwrap();
|
2015-12-27 01:38:00 +11:00
|
|
|
window.set_title("A fantastic window!");
|
2015-01-13 11:22:37 +11:00
|
|
|
|
|
|
|
let cursors = [MouseCursor::Default, MouseCursor::Crosshair, MouseCursor::Hand, MouseCursor::Arrow, MouseCursor::Move, MouseCursor::Text, MouseCursor::Wait, MouseCursor::Help, MouseCursor::Progress, MouseCursor::NotAllowed, MouseCursor::ContextMenu, MouseCursor::NoneCursor, MouseCursor::Cell, MouseCursor::VerticalText, MouseCursor::Alias, MouseCursor::Copy, MouseCursor::NoDrop, MouseCursor::Grab, MouseCursor::Grabbing, MouseCursor::AllScroll, MouseCursor::ZoomIn, MouseCursor::ZoomOut, MouseCursor::EResize, MouseCursor::NResize, MouseCursor::NeResize, MouseCursor::NwResize, MouseCursor::SResize, MouseCursor::SeResize, MouseCursor::SwResize, MouseCursor::WResize, MouseCursor::EwResize, MouseCursor::NsResize, MouseCursor::NeswResize, MouseCursor::NwseResize, MouseCursor::ColResize, MouseCursor::RowResize];
|
|
|
|
let mut cursor_idx = 0;
|
2015-12-27 01:38:00 +11:00
|
|
|
|
2017-01-29 01:45:01 +11:00
|
|
|
events_loop.run_forever(|event| {
|
2015-06-16 21:48:08 +10:00
|
|
|
match event {
|
2017-04-23 06:52:35 +10:00
|
|
|
Event::WindowEvent { event: WindowEvent::KeyboardInput { input: KeyboardInput { state: ElementState::Pressed, .. }, .. }, .. } => {
|
2015-06-16 21:48:08 +10:00
|
|
|
println!("Setting cursor to \"{:?}\"", cursors[cursor_idx]);
|
|
|
|
window.set_cursor(cursors[cursor_idx]);
|
|
|
|
if cursor_idx < cursors.len() - 1 {
|
|
|
|
cursor_idx += 1;
|
|
|
|
} else {
|
|
|
|
cursor_idx = 0;
|
|
|
|
}
|
|
|
|
},
|
2017-01-29 01:45:01 +11:00
|
|
|
Event::WindowEvent { event: WindowEvent::Closed, .. } => {
|
2017-06-20 21:25:53 +10:00
|
|
|
return ControlFlow::Break;
|
2017-01-29 01:45:01 +11:00
|
|
|
},
|
|
|
|
_ => ()
|
2015-06-16 21:48:08 +10:00
|
|
|
}
|
2017-06-08 00:12:41 +10:00
|
|
|
ControlFlow::Continue
|
2017-01-29 01:45:01 +11:00
|
|
|
});
|
2015-01-13 11:22:37 +11:00
|
|
|
}
|