cocoabits / MASShortcut

Modern framework for managing global keyboard shortcuts compatible with Mac App Store. More details:
http://blog.shpakovski.com/2012/07/global-keyboard-shortcuts-in-cocoa.html
BSD 2-Clause "Simplified" License
1.52k stars 220 forks source link

Stop working after registering the same input after cancellation #70

Closed hatashiro closed 9 years ago

hatashiro commented 9 years ago

First of all, thanks for this great job. It really saves a whole lot of my time.

I found a bug that a shortcut stops working after registering the same shortcut as before after cancelling it. This occurs in the demo app too.

Steps to Reproduce

Is there any documentation I missed or is this a bug?

Thanks in advance.

hatashiro commented 9 years ago

Just found a workaround like below, but not quite sure if it's rightly done.

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

func resetShortcutBinder() {
    MASShortcutBinder.sharedBinder().breakBindingWithDefaultsKey(shortcutKey!)
    MASShortcutBinder.sharedBinder().bindShortcutWithDefaultsKey(shortcutKey!, toAction: selectInput)
}
shpakovski commented 9 years ago

@zoul Hey Tom, I'm calling for help 😆 Maybe some cleanup needed?

zoul commented 9 years ago

I’m currently offline, will take a look at the issue on Sunday or next week. Since the bug is reproducible, it should be easy to fix.

vityevato commented 9 years ago

I think this #71

shpakovski commented 9 years ago

@noraesae Could you please verify the fix? Thanks in advance.

hatashiro commented 9 years ago

I've tested the patch and it works like a charm. Thanks!

shpakovski commented 9 years ago

Thank you all guys!