Skip to content

Instantly share code, notes, and snippets.

@fieldoffice
Last active December 19, 2015 17:48
Show Gist options
  • Save fieldoffice/5994069 to your computer and use it in GitHub Desktop.
Save fieldoffice/5994069 to your computer and use it in GitHub Desktop.
Use to prototype menubar icons and dialogues using Xcode
//
// AppDelegate.m
// Menu Bar
//
// Created by Andy Field on 05/07/2013.
// Copyright (c) 2013 Andy Field. All rights reserved.
//
#import "AppDelegate.h"
@implementation AppDelegate
NSStatusItem *statusItem;
NSMenu *theMenu;
- (void)dealloc
{
[statusItem release];
[theMenu release];
[super dealloc];
}
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
// Insert code here to initialize your application
NSMenuItem *tItem = nil;
theMenu = [[NSMenu alloc] initWithTitle:@""];
[theMenu setAutoenablesItems:NO];
[theMenu addItemWithTitle:@"Enable Application" action:nil keyEquivalent:@""];
[theMenu addItemWithTitle:@"Open System Monitor" action:nil keyEquivalent:@""];
[theMenu addItemWithTitle:@"Open Desktop Console" action:nil keyEquivalent:@""];
[theMenu addItem:[NSMenuItem separatorItem]];
[theMenu addItemWithTitle:@"Status: Enabled" action:nil keyEquivalent:@""];
[theMenu addItemWithTitle:@"Version: v01.01" action:nil keyEquivalent:@""];
[theMenu addItem:[NSMenuItem separatorItem]];
tItem = [theMenu addItemWithTitle:@"Quit" action:@selector(terminate:) keyEquivalent:@"q"];
[tItem setKeyEquivalentModifierMask:NSCommandKeyMask];
NSStatusBar *statusBar = [NSStatusBar systemStatusBar];
statusItem = [statusBar statusItemWithLength:NSVariableStatusItemLength];
[statusItem retain];
[statusItem setImage:[NSImage imageNamed:@"[email protected]"]];
[statusItem setToolTip:@"Tooltip Label"];
[statusItem setHighlightMode:YES];
[statusItem setMenu:theMenu];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment