diff --git a/platform-darwin/Source/Mac/Base.lproj/MainMenu.xib b/platform-darwin/Source/Mac/Base.lproj/MainMenu.xib index f5b3d1cc..02a42378 100644 --- a/platform-darwin/Source/Mac/Base.lproj/MainMenu.xib +++ b/platform-darwin/Source/Mac/Base.lproj/MainMenu.xib @@ -12,9 +12,6 @@ - - - @@ -241,6 +238,9 @@ + + + diff --git a/platform-darwin/Source/Mac/MPMacAppDelegate.h b/platform-darwin/Source/Mac/MPMacAppDelegate.h index 7096953b..8de27882 100644 --- a/platform-darwin/Source/Mac/MPMacAppDelegate.h +++ b/platform-darwin/Source/Mac/MPMacAppDelegate.h @@ -21,9 +21,9 @@ #import "MPSitesWindowController.h" #import "MPInitialWindowController.h" -@interface MPMacAppDelegate : MPAppDelegate_Shared +@interface MPMacAppDelegate : MPAppDelegate_Shared -@property(nonatomic, strong) NSStatusItem *statusView; +@property(nonatomic, strong) NSStatusItem *statusItem; @property(nonatomic, strong) MPSitesWindowController *sitesWindowController; @property(nonatomic, strong) MPInitialWindowController *initialWindowController; @property(nonatomic, weak) IBOutlet NSMenuItem *lockItem; diff --git a/platform-darwin/Source/Mac/MPMacAppDelegate.m b/platform-darwin/Source/Mac/MPMacAppDelegate.m index 1041210c..e3476140 100644 --- a/platform-darwin/Source/Mac/MPMacAppDelegate.m +++ b/platform-darwin/Source/Mac/MPMacAppDelegate.m @@ -158,12 +158,10 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven } forKeyPath:@"activeUser" options:0 context:nil]; // Status item. - self.statusView = [[NSStatusBar systemStatusBar] statusItemWithLength:NSSquareStatusItemLength]; - self.statusView.image = [NSImage imageNamed:@"menu-icon"]; - self.statusView.image.template = YES; - self.statusView.menu = self.statusMenu; - self.statusView.target = self; - self.statusView.action = @selector( showMenu ); + self.statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSSquareStatusItemLength]; + self.statusItem.menu = self.statusMenu; + self.statusItem.button.image = [NSImage imageNamed:@"menu-icon"]; + self.statusItem.button.image.template = YES; PearlAddNotificationObserver( NSPersistentStoreCoordinatorStoresWillChangeNotification, self.storeCoordinator, nil, ^(id self, NSNotification *note) { @@ -502,7 +500,7 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven - (IBAction)showPopup:(id)sender { - [self.statusView popUpStatusItemMenu:self.statusView.menu]; + [[self.statusItem button] performClick:sender]; } - (IBAction)showPasswordWindow:(id)sender { @@ -682,13 +680,6 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven [self updateMenuItems]; } -- (void)showMenu { - - [self updateMenuItems]; - - [self.statusView popUpStatusItemMenu:self.statusView.menu]; -} - - (void)updateMenuItems { MPUserEntity *activeUser = [self activeUserForMainThread]; @@ -743,6 +734,13 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven } } +#pragma mark - NSMenuDelegate + +- (void)menuNeedsUpdate:(NSMenu *)menu { + + [self updateMenuItems]; +} + #pragma mark - PearlConfigDelegate - (void)didUpdateConfigForKey:(SEL)configKey fromValue:(id)oldValue {