diff --git a/Cocoa/Classes/AtomWindowController.h b/Cocoa/Classes/AtomWindowController.h index 9867839bf..238d07f6c 100644 --- a/Cocoa/Classes/AtomWindowController.h +++ b/Cocoa/Classes/AtomWindowController.h @@ -8,9 +8,12 @@ #import +@class JSCocoa; + @interface AtomWindowController : NSWindowController { IBOutlet id webView; NSString *URL; + JSCocoa* jscocoa; } @property (assign) IBOutlet id webView; diff --git a/Cocoa/Classes/AtomWindowController.m b/Cocoa/Classes/AtomWindowController.m index 6926ab9b1..1efb70362 100644 --- a/Cocoa/Classes/AtomWindowController.m +++ b/Cocoa/Classes/AtomWindowController.m @@ -32,12 +32,12 @@ [webView setMainFrameURL:self.URL]; } else { - JSCocoa* jsc = [[JSCocoa alloc] initWithGlobalContext:[[webView mainFrame] globalContext]]; - [jsc setObject:self withName:@"WindowController"]; + jscocoa = [[JSCocoa alloc] initWithGlobalContext:[[webView mainFrame] globalContext]]; + [jscocoa setObject:self withName:@"WindowController"]; NSString *resourcePath = [[NSBundle mainBundle] resourcePath]; NSString *requirePath = [resourcePath stringByAppendingString:@"/src/require.js"]; - [jsc evalJSFile:requirePath]; + [jscocoa evalJSFile:requirePath]; NSURL *resourceURL = [[NSBundle mainBundle] resourceURL]; NSURL *htmlURL = [resourceURL URLByAppendingPathComponent:@"static"]; @@ -48,7 +48,9 @@ } -(BOOL) handleKeyEvent:(NSEvent *)event { - return NO; + // ICKY: Using a global function defined in App.js to deal with key events + JSValueRef returnValue = [jscocoa callJSFunctionNamed:@"handleKeyEvent" withArguments:event, nil]; + return [jscocoa toBool:returnValue]; } @end