aboutsummaryrefslogtreecommitdiffstats
path: root/src/osx
diff options
context:
space:
mode:
authorDavid Partouche <david@manateedev.com>2014-10-06 17:54:15 +0200
committerDavid Partouche <david@manateedev.com>2014-10-06 18:23:31 +0200
commit989fd1b505a51bde3f8bcd2bf9b94fa434880dd6 (patch)
tree9f862e9beb5e025bbdf376f16b29c1317018746a /src/osx
parentdb578e6e1ce88f2ceb2f0f04315aedab9e11441e (diff)
downloadglutin-989fd1b505a51bde3f8bcd2bf9b94fa434880dd6.tar.gz
glutin-989fd1b505a51bde3f8bcd2bf9b94fa434880dd6.zip
Added events handling for left/right mouse clicking
Diffstat (limited to 'src/osx')
-rw-r--r--src/osx/mod.rs39
1 files changed, 32 insertions, 7 deletions
diff --git a/src/osx/mod.rs b/src/osx/mod.rs
index 1dbe383..e61e536 100644
--- a/src/osx/mod.rs
+++ b/src/osx/mod.rs
@@ -170,23 +170,48 @@ impl Window {
}
pub fn poll_events(&self) -> Vec<Event> {
- unimplemented!()
- }
+ let mut events = Vec::new();
- pub fn wait_events(&self) -> Vec<Event> {
loop {
unsafe {
+ use {MouseInput, Pressed, Released, LeftMouseButton, RightMouseButton};
let event = NSApp().nextEventMatchingMask_untilDate_inMode_dequeue_(
NSAnyEventMask as u64,
- nil,
+ NSDate::distantPast(nil),
NSDefaultRunLoopMode,
true);
if event == nil { break; }
- NSApp().sendEvent_(event);
+
+ match event.get_type() {
+ NSLeftMouseDown => { events.push(MouseInput(Pressed, LeftMouseButton)); },
+ NSLeftMouseUp => { events.push(MouseInput(Released, LeftMouseButton)); },
+ NSRightMouseDown => { events.push(MouseInput(Pressed, RightMouseButton)); },
+ NSRightMouseUp => { events.push(MouseInput(Released, RightMouseButton)); },
+ NSMouseMoved => { },
+ NSKeyDown => { },
+ NSKeyUp => { },
+ NSFlagsChanged => { },
+ NSScrollWheel => { },
+ NSOtherMouseDown => { },
+ NSOtherMouseUp => { },
+ NSOtherMouseDragged => { },
+ _ => { },
+ }
}
}
- // TODO: Remove fake implementation
- Vec::new()
+ events
+ }
+
+ pub fn wait_events(&self) -> Vec<Event> {
+ unsafe {
+ let event = NSApp().nextEventMatchingMask_untilDate_inMode_dequeue_(
+ NSAnyEventMask as u64,
+ NSDate::distantFuture(nil),
+ NSDefaultRunLoopMode,
+ true);
+ NSApp().sendEvent_(event);
+ self.poll_events()
+ }
}
pub unsafe fn make_current(&self) {