# HG changeset patch # User Atul Varma # Date 1271061616 25200 # Node ID f2f634d576cf909c4dcfa50e08713b293ce73fc1 # Parent 0e91c6d2a547ef76c341a75b9c6d8e591f54cb25 quasimodal events now propogate to JS. diff -r 0e91c6d2a547 -r f2f634d576cf QuasimodalEventTap.m --- a/QuasimodalEventTap.m Mon Apr 12 01:09:30 2010 -0700 +++ b/QuasimodalEventTap.m Mon Apr 12 01:40:16 2010 -0700 @@ -37,7 +37,7 @@ if (inQuasimode) { if (!(flags & quasimodeKey)) { NSArray *keys = [NSArray arrayWithObjects: @"type", nil]; - NSArray *values = [NSArray arrayWithObjects: @"quasimodeEnd", nil]; + NSArray *values = [NSArray arrayWithObjects: @"quasimodeend", nil]; NSDictionary *dict = [NSDictionary dictionaryWithObjects: values forKeys: keys]; @@ -77,7 +77,7 @@ } else { if (flags & quasimodeKey) { NSArray *keys = [NSArray arrayWithObjects: @"type", nil]; - NSArray *values = [NSArray arrayWithObjects: @"quasimodeStart", nil]; + NSArray *values = [NSArray arrayWithObjects: @"quasimodestart", nil]; NSDictionary *dict = [NSDictionary dictionaryWithObjects: values forKeys: keys]; @@ -120,9 +120,9 @@ numQuasimodalKeyDowns += 1; lastQuasimodalKeyCode = keycode; lastQuasimodalKeyFlags = CGEventGetFlags(event); - eventType = @"keyDown"; + eventType = @"quasimodekeydown"; } else - eventType = @"keyUp"; + eventType = @"quasimodekeyup"; NSNumber *keycodeNum = [NSNumber numberWithUnsignedInt: keycode]; diff -r 0e91c6d2a547 -r f2f634d576cf Quasimode.m --- a/Quasimode.m Mon Apr 12 01:09:30 2010 -0700 +++ b/Quasimode.m Mon Apr 12 01:40:16 2010 -0700 @@ -12,10 +12,35 @@ #import "QuasimodalEventTap.h" @implementation Quasimode +- onEvent:(NSNotification *)notification { + NSString *type = [[notification userInfo] valueForKey: @"type"]; + DOMDocument *document = [[view mainFrame] DOMDocument]; + DOMEvent *event = [document createEvent: @"KeyboardEvent"]; + DOMKeyboardEvent *keyEvent = (DOMKeyboardEvent *) event; + [keyEvent initKeyboardEvent: type + canBubble: NO + cancelable: NO + view: [document defaultView] + keyIdentifier: nil + keyLocation: 0 + ctrlKey: NO + altKey: NO + shiftKey: NO + metaKey: YES + altGraphKey: NO]; + [document dispatchEvent: event]; +} + - (id)initWithEventSource:(NSString *)sourceName { if (self = [super init]) { eventSource = [sourceName copy]; + [[NSNotificationCenter defaultCenter] + addObserver: self + selector: @selector(onEvent:) + name: @"QuasimodeEvent" + object: eventSource]; + NSRect rect = {{20, 20}, {100, 100}};