diff options
| author | Vadim Shpakovski | 2014-09-17 19:00:06 +0300 |
|---|---|---|
| committer | Vadim Shpakovski | 2014-09-17 19:00:06 +0300 |
| commit | 8e196a14a09a7a16d19c6cf9c3985eea7f7b7554 (patch) | |
| tree | a284a46c044c63864597f0f4f1db89a57da6eba0 /MASShortcutView.m | |
| parent | 0633545a4666d969dfbb860e540eb3b008893651 (diff) | |
| parent | e53eed24bc6cc2856e732b16832730f6c2aa2827 (diff) | |
| download | MASShortcut-8e196a14a09a7a16d19c6cf9c3985eea7f7b7554.tar.bz2 | |
Merge pull request #45 from pfandrade/master1.3
Implemented initWithCoder: to fix #44
Diffstat (limited to 'MASShortcutView.m')
| -rw-r--r-- | MASShortcutView.m | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/MASShortcutView.m b/MASShortcutView.m index 96dcc86..b2d2531 100644 --- a/MASShortcutView.m +++ b/MASShortcutView.m @@ -42,15 +42,29 @@ { self = [super initWithFrame:frameRect]; if (self) { - _shortcutCell = [[[self.class shortcutCellClass] alloc] init]; - _shortcutCell.buttonType = NSPushOnPushOffButton; - _shortcutCell.font = [[NSFontManager sharedFontManager] convertFont:_shortcutCell.font toSize:BUTTON_FONT_SIZE]; - _enabled = YES; - [self resetShortcutCellStyle]; + [self commonInit]; } return self; } +- (id)initWithCoder:(NSCoder *)coder +{ + self = [super initWithCoder:coder]; + if (self) { + [self commonInit]; + } + return self; +} + +- (void)commonInit +{ + _shortcutCell = [[[self.class shortcutCellClass] alloc] init]; + _shortcutCell.buttonType = NSPushOnPushOffButton; + _shortcutCell.font = [[NSFontManager sharedFontManager] convertFont:_shortcutCell.font toSize:BUTTON_FONT_SIZE]; + _enabled = YES; + [self resetShortcutCellStyle]; +} + - (void)dealloc { [self activateEventMonitoring:NO]; @@ -380,17 +394,16 @@ void *kUserDataHint = &kUserDataHint; [weakSelf activateEventMonitoring:NO]; NSString *format = NSLocalizedString(@"The key combination %@ cannot be used", @"Title for alert when shortcut is already used"); - NSAlert* alert = [[NSAlert alloc]init]; - alert.messageText = [NSString stringWithFormat:format, shortcut]; - alert.informativeText = error.localizedDescription; - alert.alertStyle = NSWarningAlertStyle; - weakSelf.recording = NO; - [alert beginSheetModalForWindow:self.window completionHandler:^(NSModalResponse returnCode) { - weakSelf.shortcutPlaceholder = nil; - [weakSelf activateResignObserver:YES]; - [weakSelf activateEventMonitoring:YES]; - weakSelf.recording = YES; - }]; + NSAlert *alert = [[NSAlert alloc] init]; + alert.alertStyle = NSCriticalAlertStyle; + alert.informativeText = [NSString stringWithFormat:format, shortcut]; + alert.messageText = error.localizedDescription; + [alert addButtonWithTitle:NSLocalizedString(@"OK", @"Alert button when shortcut is already used")]; + + [alert runModal]; + weakSelf.shortcutPlaceholder = nil; + [weakSelf activateResignObserver:YES]; + [weakSelf activateEventMonitoring:YES]; } else { weakSelf.shortcutValue = shortcut; |
