Created
September 11, 2010 23:12
-
-
Save orlaqp/575658 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
var myApp = [CPApplication sharedApplication], | |
myMenu = [myApp mainMenu]; | |
// Cloud Books | |
var cloudBooksMenu = [[CPMenu alloc] initWithTitle:@"Cloud Books"], | |
cloudBooksMenuItem = [[CPMenuItem alloc] initWithTitle:@"Cloud Books" action:nil keyEquivalent:nil]; | |
var backupMenuItem = [[CPMenuItem alloc] initWithTitle:@"Backup" action:@selector(backup:) keyEquivalent:@"B"]; | |
var logoffMenuItem = [[CPMenuItem alloc] initWithTitle:@"Logoff" action:@selector(logoff) keyEquivalent:@"L"]; | |
[backupMenuItem setTarget:self]; | |
[logoffMenuItem setTarget:self]; | |
[cloudBooksMenu addItem:backupMenuItem]; | |
[cloudBooksMenu addItem:logoffMenuItem]; | |
[cloudBooksMenuItem setSubmenu:cloudBooksMenu]; | |
// List Menu | |
var listMenu = [[CPMenu alloc] initWithTitle:@"Lists"], | |
listMenuItem = [[CPMenuItem alloc] initWithTitle:@"Lists" action:nil keyEquivalent:nil]; | |
[listMenu addItem:[[CPMenuItem alloc] initWithTitle:@"Accounts" action:@selector(zoomIn:) keyEquivalent:@"+"]]; | |
[listMenu addItem:[[CPMenuItem alloc] initWithTitle:@"Items" action:@selector(zoomOut:) keyEquivalent:@"-"]]; | |
[listMenuItem setSubmenu:listMenu]; | |
// Can't just addItem because of strut aftr Edit menu. | |
var theIndex = [myMenu indexOfItemWithTitle: @"Edit"]; | |
[myMenu insertItem:cloudBooksMenuItem atIndex: theIndex+1]; | |
[myMenu insertItem:listMenuItem atIndex: theIndex+2]; | |
var theNewIndex = [myMenu indexOfItemWithTitle: @"New" ]; | |
var theOpenIndex = [myMenu indexOfItemWithTitle: @"Open"]; | |
var theSaveIndex = [myMenu indexOfItemWithTitle: @"Save"]; | |
// N.B. You have to unwind the menus in reverse order. | |
[myMenu removeItemAtIndex:theSaveIndex]; | |
[myMenu removeItemAtIndex:theOpenIndex]; | |
[myMenu removeItemAtIndex:theNewIndex]; | |
[CPMenu setMenuBarVisible:YES]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment