diff options
author | David Partouche <david@manateedev.com> | 2014-10-12 20:16:42 +0200 |
---|---|---|
committer | David Partouche <david@manateedev.com> | 2014-10-23 17:30:16 +0200 |
commit | dad539114dbbc4717611ce92d8422b2f5127a597 (patch) | |
tree | b0b430b53c2b9109ba695b1327fb09718bd0295e /src/osx/mod.rs | |
parent | ba8f55547f18e7fa01d29d945b961476ea1658e0 (diff) | |
download | glutin-dad539114dbbc4717611ce92d8422b2f5127a597.tar.gz glutin-dad539114dbbc4717611ce92d8422b2f5127a597.zip |
Added ReceivedCharacter event for cocoa
Diffstat (limited to 'src/osx/mod.rs')
-rw-r--r-- | src/osx/mod.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/osx/mod.rs b/src/osx/mod.rs index d194c21..7d17aac 100644 --- a/src/osx/mod.rs +++ b/src/osx/mod.rs @@ -14,6 +14,8 @@ use core_foundation::base::TCFType; use core_foundation::string::CFString; use core_foundation::bundle::{CFBundleGetBundleWithIdentifier, CFBundleGetFunctionPointerForName}; +use std::c_str::CString; + pub struct Window { window: id, view: id, @@ -210,7 +212,7 @@ impl Window { loop { unsafe { - use {MouseInput, Pressed, Released, LeftMouseButton, RightMouseButton, MouseMoved}; + use {MouseInput, Pressed, Released, LeftMouseButton, RightMouseButton, MouseMoved, ReceivedCharacter}; let event = NSApp().nextEventMatchingMask_untilDate_inMode_dequeue_( NSAnyEventMask as u64, NSDate::distantPast(nil), @@ -229,7 +231,13 @@ impl Window { let view_point = self.view.convertPoint_fromView_(window_point, nil); events.push(MouseMoved((view_point.x as int, view_point.y as int))); }, - NSKeyDown => { }, + NSKeyDown => { + let received_cstr = CString::new(event.characters().UTF8String(), false); + match received_cstr.as_str() { + Some(received_str) => { events.push(ReceivedCharacter(received_str.char_at(0))); }, + None => { }, + }; + }, NSKeyUp => { }, NSFlagsChanged => { }, NSScrollWheel => { }, |