PageRenderTime 28ms CodeModel.GetById 2ms app.highlight 22ms RepoModel.GetById 1ms app.codeStats 0ms

/Tools/NativeHost/Application.m

http://github.com/cacaodev/cappuccino
Objective C | 49 lines | 32 code | 10 blank | 7 comment | 5 complexity | eb407e8ad3cf741adc8f84574c48b157 MD5 | raw file
 1//
 2//  Application.m
 3//  NativeHost
 4//
 5//  Created by Francisco Tolmasky on 10/8/09.
 6//  Copyright 2009 280 North, Inc.. All rights reserved.
 7//
 8
 9#import "Application.h"
10#import "AppController.h"
11#import "WebScripObject+Objective-J.h"
12#import "WebWindow.h"
13
14@implementation Application
15
16- (void)sendEvent:(NSEvent *)anEvent
17{
18    [WebWindow enableAllWindows];
19
20    NSWindow * window = [anEvent window];
21
22    if (!window || [window isKindOfClass:[WebWindow class]])
23    {
24        NSResponder * firstResponder = window ? [window firstResponder] : [(AppController *)[self delegate] keyView];
25
26        switch ([anEvent type])
27        {
28            case NSKeyDown: return [firstResponder keyDown:anEvent];
29            case NSKeyUp:   return [firstResponder keyUp:anEvent];
30        }
31    }
32
33    [super sendEvent:anEvent];
34}
35
36- (void)terminate:(id)sender
37{
38    if ([[[self delegate] windowScriptObject] evaluateObjectiveJ:@"(CPApp)"] == [WebUndefined undefined])
39        [self _reallyTerminate:sender];
40    else
41        [[(AppController *)[self delegate] windowScriptObject] evaluateObjectiveJ:@"[CPApp terminate:nil]"];
42}
43
44- (void)_reallyTerminate:(id)sender
45{
46    [super terminate:sender];
47}
48
49@end