Skip to content

Instantly share code, notes, and snippets.

@linuxsable
Created November 21, 2013 08:26
Show Gist options
  • Save linuxsable/7577859 to your computer and use it in GitHub Desktop.
Save linuxsable/7577859 to your computer and use it in GitHub Desktop.
//
// StatusBarAppAppDelegate.m
// StatusBarApp
//
// Created by CCoding on 18.09.11.
// Copyright 2011 CCoding. All rights reserved.
//
#import "StatusBarAppAppDelegate.h"
@implementation StatusBarAppAppDelegate
- (void)awakeFromNib {
statusItem = [[[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength] retain];
NSBundle *bundle = [NSBundle mainBundle];
statusImage = [[NSImage alloc] initWithContentsOfFile:[bundle pathForResource:@"Icon1" ofType:@"png"]];
statusHighlightImage = [[NSImage alloc] initWithContentsOfFile:[bundle pathForResource:@"Icon2" ofType:@"png"]];
[statusItem setImage:statusImage];
[statusItem setAlternateImage:statusHighlightImage];
//Use a title instead of images
//[statusItem setTitle:@"This text will appear instead of images"];
[statusItem setMenu:statusMenu];
[statusItem setToolTip:@"You do not need this..."];
[statusItem setHighlightMode:YES];
// [NSEvent addGlobalMonitorForEventsMatchingMask:NSKeyDownMask handler:^(NSEvent *event) {
// NSString *chars = [[event characters] lowercaseString];
// unichar character = [chars characterAtIndex:0];
// NSLog(@"keydown globally! Which key? This key: %c", character);
// }];
}
- (void)applicationDidFinishLaunching:(NSNotification *)notification {
NSLog(AXIsProcessTrusted() ? @"true" : @"false");
[NSEvent addGlobalMonitorForEventsMatchingMask:NSKeyDownMask handler: ^(NSEvent *event) {
NSUInteger flags = [event modifierFlags] & NSDeviceIndependentModifierFlagsMask;
NSLog(@"hi");
if (flags == NSControlKeyMask + NSShiftKeyMask) {
}
}];
}
- (IBAction)doSomething:(id)sender {
NSLog(@"Is doing something");
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment