/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. #import "Application.h"
  9. #import "AppController.h"
  10. #import "WebScripObject+Objective-J.h"
  11. #import "WebWindow.h"
  12. @implementation Application
  13. - (void)sendEvent:(NSEvent *)anEvent
  14. {
  15. [WebWindow enableAllWindows];
  16. NSWindow * window = [anEvent window];
  17. if (!window || [window isKindOfClass:[WebWindow class]])
  18. {
  19. NSResponder * firstResponder = window ? [window firstResponder] : [(AppController *)[self delegate] keyView];
  20. switch ([anEvent type])
  21. {
  22. case NSKeyDown: return [firstResponder keyDown:anEvent];
  23. case NSKeyUp: return [firstResponder keyUp:anEvent];
  24. }
  25. }
  26. [super sendEvent:anEvent];
  27. }
  28. - (void)terminate:(id)sender
  29. {
  30. if ([[[self delegate] windowScriptObject] evaluateObjectiveJ:@"(CPApp)"] == [WebUndefined undefined])
  31. [self _reallyTerminate:sender];
  32. else
  33. [[(AppController *)[self delegate] windowScriptObject] evaluateObjectiveJ:@"[CPApp terminate:nil]"];
  34. }
  35. - (void)_reallyTerminate:(id)sender
  36. {
  37. [super terminate:sender];
  38. }
  39. @end