MenuItemView/AppDelegate.m
/* |
Copyright (C) 2017 Apple Inc. All Rights Reserved. |
See LICENSE.txt for this sample’s licensing information |
Abstract: |
Header file for this sample's application delegate. |
*/ |
#import "AppDelegate.h" |
@interface AppDelegate () |
@property (strong) NSMenu *appDockMenu; |
@end |
#pragma mark - |
@implementation AppDelegate |
// ------------------------------------------------------------------------------- |
// aboutDockAction:sender |
// ------------------------------------------------------------------------------- |
- (void)aboutDockAction:(id)sender |
{ |
[[NSApplication sharedApplication] orderFrontStandardAboutPanel:self]; |
} |
// ------------------------------------------------------------------------------- |
// applicationDidFinishLaunching:notification |
// ------------------------------------------------------------------------------- |
- (void)applicationDidFinishLaunching:(NSNotification *)notification |
{ |
// add an "About" menu item to our Dock menu |
_appDockMenu = [[NSMenu alloc] initWithTitle:NSLocalizedString(@"DocMenu", @"")]; |
[self.appDockMenu setAutoenablesItems:NO]; |
NSMenuItem *newItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"About", @"") |
action:@selector(aboutDockAction:) |
keyEquivalent:@""]; |
newItem.target = self; |
[self.appDockMenu addItem:newItem]; |
} |
// ------------------------------------------------------------------------------- |
// applicationDockMenu:sender |
// ------------------------------------------------------------------------------- |
// This NSApplication delegate method is called when the user clicks and holds on |
// the application icon in the dock. |
// |
- (NSMenu *)applicationDockMenu:(NSApplication *)sender |
{ |
return self.appDockMenu; |
} |
@end |
Copyright © 2017 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2017-03-09