aboutsummaryrefslogtreecommitdiffstats
path: root/src/api/cocoa
diff options
context:
space:
mode:
authorFelix Kaaman <trundmatu@gmail.com>2015-04-24 15:53:02 +0200
committerFelix Kaaman <trundmatu@gmail.com>2015-04-24 15:53:02 +0200
commit44e954895fd6c3497c8b5483e1b3efe160429329 (patch)
tree3f94675e20b361ba1c0809ab8454b1d8926e1f1b /src/api/cocoa
parent4dee36631c520726179139bd543453ff0f3b78d6 (diff)
downloadglutin-44e954895fd6c3497c8b5483e1b3efe160429329.tar.gz
glutin-44e954895fd6c3497c8b5483e1b3efe160429329.zip
Fix alert sounds on keypress on cocoa
Passing on keypress event to parent would make it think the event was not consumed and emit an alert sound.
Diffstat (limited to 'src/api/cocoa')
-rw-r--r--src/api/cocoa/mod.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/api/cocoa/mod.rs b/src/api/cocoa/mod.rs
index b9c566f..96bf842 100644
--- a/src/api/cocoa/mod.rs
+++ b/src/api/cocoa/mod.rs
@@ -199,9 +199,11 @@ impl<'a> Iterator for PollEventsIterator<'a> {
NSDefaultRunLoopMode,
YES);
if event == nil { return None; }
- NSApp().sendEvent_(event);
- let event = match msg_send![event, type] {
+ let event_type = msg_send![event, type];
+ NSApp().sendEvent_(if let NSKeyDown = event_type { nil } else { event });
+
+ let event = match event_type {
NSLeftMouseDown => { Some(MouseInput(Pressed, MouseButton::Left)) },
NSLeftMouseUp => { Some(MouseInput(Released, MouseButton::Left)) },
NSRightMouseDown => { Some(MouseInput(Pressed, MouseButton::Right)) },
@@ -220,6 +222,7 @@ impl<'a> Iterator for PollEventsIterator<'a> {
};
let view_rect = NSView::frame(*self.window.view);
let scale_factor = self.window.hidpi_factor();
+
Some(MouseMoved(((scale_factor * view_point.x as f32) as i32,
(scale_factor * (view_rect.size.height - view_point.y) as f32) as i32)))
},
@@ -241,6 +244,7 @@ impl<'a> Iterator for PollEventsIterator<'a> {
},
NSKeyUp => {
let vkey = event::vkeycode_to_element(NSEvent::keyCode(event));
+
Some(KeyboardInput(Released, NSEvent::keyCode(event) as u8, vkey))
},
NSFlagsChanged => {
@@ -273,8 +277,6 @@ impl<'a> Iterator for PollEventsIterator<'a> {
_ => { None },
};
-
-
event
}
}