diff options
| author | Tomáš Znamenáček | 2015-01-08 10:47:25 +0100 |
|---|---|---|
| committer | Tomáš Znamenáček | 2015-01-08 10:47:25 +0100 |
| commit | d2a371c92e7570042f52cced866c383ebe6e4268 (patch) | |
| tree | 394c16e48b486e184ecfe56fc09d9e3a26622adb /Framework | |
| parent | 4a32eca2e6717e778294d492e66c484392cfc2ec (diff) | |
| download | MASShortcut-d2a371c92e7570042f52cced866c383ebe6e4268.tar.bz2 | |
Documented the recording control behaviour and implemented Cmd-W/Q.
Diffstat (limited to 'Framework')
| -rw-r--r-- | Framework/MASShortcutView.m | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/Framework/MASShortcutView.m b/Framework/MASShortcutView.m index a449829..aace67e 100644 --- a/Framework/MASShortcutView.m +++ b/Framework/MASShortcutView.m @@ -373,18 +373,27 @@ void *kUserDataHint = &kUserDataHint; NSEventMask eventMask = (NSKeyDownMask | NSFlagsChangedMask); eventMonitor = [NSEvent addLocalMonitorForEventsMatchingMask:eventMask handler:^(NSEvent *event) { + // Create a shortcut from the event MASShortcut *shortcut = [MASShortcut shortcutWithEvent:event]; - if ((shortcut.modifierFlags == 0) && ((shortcut.keyCode == kVK_Delete) || (shortcut.keyCode == kVK_ForwardDelete))) { - // Delete shortcut + + // If the shortcut is a plain Delete or Backspace, clear the current shortcut and cancel recording + if (!shortcut.modifierFlags && ((shortcut.keyCode == kVK_Delete) || (shortcut.keyCode == kVK_ForwardDelete))) { weakSelf.shortcutValue = nil; weakSelf.recording = NO; event = nil; } - else if (shortcut.keyCode == kVK_Escape && !shortcut.modifierFlags) { - // Cancel recording + + // If the shortcut is a plain Esc, cancel recording + else if (!shortcut.modifierFlags && shortcut.keyCode == kVK_Escape) { weakSelf.recording = NO; event = nil; } + + // If the shortcut is Cmd-W or Cmd-Q, cancel recording and pass the event through + else if ((shortcut.modifierFlags == NSCommandKeyMask) && (shortcut.keyCode == kVK_ANSI_W || shortcut.keyCode == kVK_ANSI_Q)) { + weakSelf.recording = NO; + } + else { // Verify possible shortcut if (shortcut.keyCodeString.length > 0) { |
