aboutsummaryrefslogtreecommitdiffstats
path: root/Demo/AppDelegate.m
blob: 5c1c3f752de0e37ce690860037ec9282d0c3df3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#import "AppDelegate.h"

@interface AppDelegate ()
@property (nonatomic, assign) IBOutlet MASShortcutView *shortcutView;
@end

@implementation AppDelegate

- (void) awakeFromNib
{
    [super awakeFromNib];

    static NSString *const ShortcutKey = @"customShortcut";

    // Bind the shortcut recorder views value to user defaults.
    // Rundefaults read com.shpakovski.mac.Demoto see whats stored
    // in user defaults.
    [_shortcutView setAssociatedUserDefaultsKey:ShortcutKey];

    // Play a ping sound when the shortcut stored in user defaults is pressed.
    // Note that when the shortcut stored in user defaults changes, you dont have
    // to update anything: the old shortcut will automatically stop working and
    // the sound will play after pressing the new one.
    [[MASShortcutBinder sharedBinder] bindShortcutWithDefaultsKey:ShortcutKey toAction:^{
        [[NSSound soundNamed:@"Ping"] play];
    }];
}

#pragma mark NSApplicationDelegate

- (BOOL) applicationShouldTerminateAfterLastWindowClosed: (NSApplication*) sender
{
    return YES;
}

@end