Skip to content

Commit

Permalink
Fix the problem that a shortcut stops working in some cases.
Browse files Browse the repository at this point in the history
For details, please refer to the issue below.

cocoabits/MASShortcut#70
  • Loading branch information
Hyunje Alex Jun committed Aug 6, 2015
1 parent 06f71fb commit 8a00698
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions kawa/ShortcutCellView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ class ShortcutCellView: NSTableCellView {
self.inputSource = inputSource
shortcutKey = inputSource.id.stringByReplacingOccurrencesOfString(".", withString: "-")
shortcutView.associatedUserDefaultsKey = shortcutKey!
shortcutView.shortcutValueChange = self.shortcutValueDidChanged
MASShortcutBinder.sharedBinder().bindShortcutWithDefaultsKey(shortcutKey!, toAction: selectInput)
}

func shortcutValueDidChanged(sender: MASShortcutView!) {
if sender.shortcutValue == nil {
resetShortcutBinder()
}
}

func resetShortcutBinder() {
MASShortcutBinder.sharedBinder().breakBindingWithDefaultsKey(shortcutKey!)
MASShortcutBinder.sharedBinder().bindShortcutWithDefaultsKey(shortcutKey!, toAction: selectInput)
}

Expand Down

0 comments on commit 8a00698

Please sign in to comment.