aboutsummaryrefslogtreecommitdiffstats
path: root/src/osx
diff options
context:
space:
mode:
Diffstat (limited to 'src/osx')
-rw-r--r--src/osx/event.rs18
-rw-r--r--src/osx/mod.rs12
2 files changed, 5 insertions, 25 deletions
diff --git a/src/osx/event.rs b/src/osx/event.rs
index a4128a4..b5853bc 100644
--- a/src/osx/event.rs
+++ b/src/osx/event.rs
@@ -1,25 +1,7 @@
use events;
-use events::KeyModifiers;
use cocoa::base::NSUInteger;
use cocoa::appkit;
-pub fn modifierflag_to_element(flag: NSUInteger) -> KeyModifiers {
- let mut modifiers = KeyModifiers::empty();
- if flag & appkit::NSShiftKeyMask as u64 == appkit::NSShiftKeyMask as u64 {
- modifiers = modifiers | events::LEFT_SHIFT_MODIFIER;
- }
- if flag & appkit::NSControlKeyMask as u64 == appkit::NSControlKeyMask as u64 {
- modifiers = modifiers | events::LEFT_CONTROL_MODIFIER;
- }
- if flag & appkit::NSAlternateKeyMask as u64 == appkit::NSAlternateKeyMask as u64 {
- modifiers = modifiers | events::LEFT_ALT_MODIFIER;
- }
- if flag & appkit::NSNumericPadKeyMask as u64 == appkit::NSNumericPadKeyMask as u64 {
- modifiers = modifiers | events::NUM_LOCK_MODIFIER;
- }
- modifiers
-}
-
pub fn vkeycode_to_element(code: u16) -> Option<events::VirtualKeyCode> {
Some(match code {
0x00 => events::A,
diff --git a/src/osx/mod.rs b/src/osx/mod.rs
index de7e902..ea79f04 100644
--- a/src/osx/mod.rs
+++ b/src/osx/mod.rs
@@ -18,7 +18,7 @@ use core_foundation::bundle::{CFBundleGetBundleWithIdentifier, CFBundleGetFuncti
use std::c_str::CString;
use {MouseInput, Pressed, Released, LeftMouseButton, RightMouseButton, MouseMoved, ReceivedCharacter,
- KeyboardInput, KeyModifiers};
+ KeyboardInput};
use events;
@@ -252,13 +252,11 @@ impl Window {
}
let vkey = event::vkeycode_to_element(event.keycode());
- let modifiers = event::modifierflag_to_element(event.modifierFlags());
- events.push(KeyboardInput(Pressed, event.keycode() as u8, vkey, modifiers));
+ events.push(KeyboardInput(Pressed, event.keycode() as u8, vkey));
},
NSKeyUp => {
let vkey = event::vkeycode_to_element(event.keycode());
- let modifiers = event::modifierflag_to_element(event.modifierFlags());
- events.push(KeyboardInput(Released, event.keycode() as u8, vkey, modifiers));
+ events.push(KeyboardInput(Released, event.keycode() as u8, vkey));
},
NSFlagsChanged => {
let shift_modifier = Window::modifier_event(event, appkit::NSShiftKeyMask as u64, events::LShift, shift_pressed);
@@ -295,10 +293,10 @@ impl Window {
unsafe fn modifier_event(event: id, keymask: u64, key: events::VirtualKeyCode, key_pressed: bool) -> Option<Event> {
if !key_pressed && Window::modifier_key_pressed(event, keymask) {
- return Some(KeyboardInput(Pressed, event.keycode() as u8, Some(key), KeyModifiers::empty()));
+ return Some(KeyboardInput(Pressed, event.keycode() as u8, Some(key)));
}
else if key_pressed && !Window::modifier_key_pressed(event, keymask) {
- return Some(KeyboardInput(Released, event.keycode() as u8, Some(key), KeyModifiers::empty()));
+ return Some(KeyboardInput(Released, event.keycode() as u8, Some(key)));
}
return None;