summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJess VanDerwalker <washu@sonic.net>2012-07-26 22:53:15 -0700
committerJess VanDerwalker <washu@sonic.net>2012-07-26 22:53:15 -0700
commit402cb8e4cd43052a7649a182ca7bae1490b1cd43 (patch)
tree2885eb09345f2a08ae7f238cc38391d31018a13d
parent1ca918316ef49af369f3b20245c1694945d2466c (diff)
xtoq: NSFlagsChanged case added to XtoqApplication sendEvent()
Press and release of modifier keys are not passed by NSKeyUp or NSKeyDown events, but in NSFlagsChanged. Added an NSFlagsChanged case to the sendEvent switch. The modifier flags of the event are checked against the current set of modifier flags to determine if the modifier key, as specified in the event's keyCode, has been pressed or released. Keycode is then sent on to keyUp/DownInView handler. Signed-off-by: Jess VanDerwalker <washu@sonic.net> Reviewed-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
-rw-r--r--src/xtoq/XtoqApplication.m49
-rw-r--r--src/xtoq/XtoqController.m3
2 files changed, 49 insertions, 3 deletions
diff --git a/src/xtoq/XtoqApplication.m b/src/xtoq/XtoqApplication.m
index fe323db..3fcea9d 100644
--- a/src/xtoq/XtoqApplication.m
+++ b/src/xtoq/XtoqApplication.m
@@ -274,6 +274,55 @@ XtoqApplicationMain(int argc, char** argv)
break;
}
+ case NSFlagsChanged:
+ {
+ static int currentModFlags = 0;
+ int modFlags = [e modifierFlags];
+ BOOL key_pressed = NO;
+
+ if (modFlags & NSAlphaShiftKeyMask) {
+ NSLog(@"Alpha key mask");
+ }
+
+ if ((modFlags & NSShiftKeyMask)
+ && !(currentModFlags & NSShiftKeyMask)) {
+ key_pressed = YES;
+ }
+
+ if ((modFlags & NSControlKeyMask)
+ && !(currentModFlags & NSControlKeyMask)) {
+ key_pressed = YES;
+ }
+
+ if ((modFlags & NSAlternateKeyMask)
+ && !(currentModFlags & NSAlternateKeyMask)) {
+ key_pressed = YES;
+ }
+
+ if ((modFlags & NSCommandKeyMask)
+ && !(currentModFlags & NSCommandKeyMask)) {
+ key_pressed = YES;
+ }
+
+ if (key_pressed) {
+ NSDictionary * dictionary =
+ [NSDictionary dictionaryWithObject:e
+ forKey:@"1"];
+ [notificationCenter postNotificationName:@"XTOQviewKeyDownEvent"
+ object:self
+ userInfo:dictionary];
+ } else {
+ NSDictionary * dictionary =
+ [NSDictionary dictionaryWithObject:e
+ forKey:@"1"];
+ [notificationCenter postNotificationName:@"XTOQviewKeyUpEvent"
+ object:self
+ userInfo:dictionary];
+ }
+ currentModFlags = modFlags;
+ break;
+ }
+
default:
break;
}
diff --git a/src/xtoq/XtoqController.m b/src/xtoq/XtoqController.m
index 1821c4c..8965a8c 100644
--- a/src/xtoq/XtoqController.m
+++ b/src/xtoq/XtoqController.m
@@ -192,10 +192,7 @@
// note this keyInfo is the key in <key, value> not the key pressed
NSEvent * event = [keyInfo objectForKey: @"1"];
unsigned short aChar = [event keyCode];
- NSString* charNSString = [event characters];
- const char* charcharstar = [charNSString UTF8String];
- NSLog(@"%s pressed", charcharstar);
// FIXME: Uses a 'magic number' for offset into keymap - should a
// #define or gotten programmatically.
dispatch_async(xcwmDispatchQueue,