Created
July 9, 2014 07:47
-
-
Save skela/87cf62944fbfc23cb83c to your computer and use it in GitHub Desktop.
Revisions
-
skela created this gist
Jul 9, 2014 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { self.statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSSquareStatusItemLength]; self.statusItem.target = self; self.statusItem.action = @selector(clickStatusItem:); [self.statusItem sendActionOn:(NSLeftMouseDownMask|NSRightMouseDownMask)]; NSImage *img = [NSImage imageNamed:@"icon_empty"]; [img setTemplate:YES]; self.statusItem.image = img; } - (IBAction)clickStatusItem:(id)sender { BOOL rightClick = (([[NSApp currentEvent] modifierFlags] & NSControlKeyMask) == NSControlKeyMask) || ([[NSApp currentEvent] type] == NSRightMouseDown); if (rightClick) { [self singleRightClickedStatusItem:sender]; } else { [self singleLeftClickedStatusItem:sender]; } } -(IBAction)singleLeftClickedStatusItem:(id)sender { NSLog(@"Left Clicked Status Item"); } -(IBAction)singleRightClickedStatusItem:(id)sender { NSLog(@"Right Clicked Status Item"); }