Oolite 1.91.0.7646-241128-10e222e
Loading...
Searching...
No Matches
OoliteApp.m
Go to the documentation of this file.
1/*
2
3OoliteApp.m
4
5Oolite
6Copyright (C) 2004-2013 Giles C Williams and contributors
7
8This program is free software; you can redistribute it and/or
9modify it under the terms of the GNU General Public License
10as published by the Free Software Foundation; either version 2
11of the License, or (at your option) any later version.
12
13This program is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License
19along with this program; if not, write to the Free Software
20Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21MA 02110-1301, USA.
22
23*/
24
25#import "OoliteApp.h"
26#import "GameController.h"
27#import "MyOpenGLView.h"
28
29
30@implementation OoliteApp
31
32- (void)sendEvent:(NSEvent *)theEvent
33{
34 NSEventType etype = [theEvent type];
36
37 if ([NSApp keyWindow] == _gameWindow)
38 {
39 // Ensure key events are handled at least once when game window is key
40 switch (etype)
41 {
42 case NSKeyDown:
43 [gameView keyDown:theEvent];
44 break;
45
46 case NSKeyUp:
47 [gameView keyUp:theEvent];
48 break;
49
50 default:
51 break;
52 }
53 }
54 [super sendEvent:theEvent]; // perform the default event behaviour
55}
56
57
58- (void) setExitContext:(NSString *)exitContext
59{
60 [_exitContext release];
61 _exitContext = [exitContext copy];
62}
63
64
65- (void) terminate:(id)sender
66{
67 if (_exitContext == nil) [self setExitContext:@"Cocoa terminate event"];
68 OOLog(@"exit.context", @"Exiting: %@.", _exitContext);
69 [super terminate:sender];
70}
71
72@end
#define OOLog(class, format,...)
Definition OOLogging.h:88
return nil
IBOutlet MyOpenGLView * gameView
void keyDown:(NSEvent *theEvent)
void keyUp:(NSEvent *theEvent)
NSString * _exitContext
Definition OoliteApp.h:42
IBOutlet GameController * _gameController
Definition OoliteApp.h:41
IBOutlet NSWindow * _gameWindow
Definition OoliteApp.h:40