Created
May 6, 2009 00:29
-
-
Save andrewsardone/107299 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "AppController.h" | |
@implementation AppController | |
- (void)awakeFromNib { | |
NSMenu *menu = [self createMenu]; | |
menuItem = [[[NSStatusBar systemStatusBar] statusItemWithLength:24] retain]; | |
[menuItem setImage:[NSImage imageNamed:@"41-picture-frame"]]; | |
[menuItem setTarget:self]; | |
[menuItem setAction:@selector(menuItemClick:)]; | |
[menuItem setMenu:menu]; | |
[menuItem setHighlightMode:YES]; | |
} | |
- (void)menuItemClick:(id)sender{ | |
if ([oMainWindow isVisible]) { | |
if ([oMainWindow isKeyWindow]) { | |
[oMainWindow performClose:self]; | |
} else { | |
[NSApp activateIgnoringOtherApps:YES]; | |
} | |
} else { | |
[NSApp activateIgnoringOtherApps:YES]; | |
[oMainWindow makeKeyAndOrderFront:self]; | |
} | |
} | |
- (NSMenu *)createMenu { | |
NSZone *menuZone = [NSMenu menuZone]; | |
NSMenu *menu = [[NSMenu allocWithZone:menuZone] init]; | |
NSMenuItem *menuItem = [menu addItemWithTitle:@"Quit" action:@selector(appTerminate:) keyEquivalent:@""]; | |
[menuItem setTarget:self]; | |
return menu; | |
} | |
- (void)appTerminate:(id)sender { | |
[NSApp terminate:sender]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment