#ifdef PLATFORM_MAC
NSDictionary * aboutOptions = [NSDictionary
dictionaryWithObjectsAndKeys:@"Credits", @"Credits.rtf",
nil];
@interface MenuNotification : NSObject <NSApplicationDelegate>
- (void) terminateRequest: (id)sender;
- (void) performAbout: (id)sender;
@end
@implementation MenuNotification
- (void) performAbout: (id)sender
{
[ NSApp orderFrontStandardAboutPanelWithOptions: aboutOptions ];
}
- (void) terminateRequest: (id)sender
{
//set our main loop to end
DirectReality->running = false;
}
@end
MenuNotification * menuNotify;
#endif
#ifdef PLATFORM_MAC
menuNotify = [[MenuNotification alloc]init];
[NSApp setDelegate: menuNotify];
id menubar = [[NSMenu new] autorelease];
id appMenuItem = [[NSMenuItem new] autorelease];
[menubar addItem:appMenuItem];
[NSApp setMainMenu:menubar];
id appMenu = [[NSMenu new] autorelease];
id appName = [[NSProcessInfo processInfo] processName];
NSString *title;
title = [@"About " stringByAppendingString:appName];
[appMenu addItemWithTitle:title action:@selector(performAbout:) keyEquivalent:@""];
[appMenu addItem:[NSMenuItem separatorItem]];
id quitTitle = [@"Quit " stringByAppendingString:appName];
id quitMenuItem = [[[NSMenuItem alloc] initWithTitle:quitTitle
action:@selector(terminateRequest:) keyEquivalent:@"q"] autorelease];
[appMenu addItem:quitMenuItem];
[appMenuItem setSubmenu:appMenu];
#endif
Anyways no promises on how great that code is. I really don't touch Obj C unless its just to write something once and then wrap it away so I don't have to see it again, but it seems to work just fine.