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

Register shortcuts in non-exclusive mode #56

Closed zoul closed 9 years ago

zoul commented 9 years ago

During my work on the support for older OS X versions I stumbled upon a bug where a shortcut would refuse to register saying it’s already registered. This lead me to the kEventHotKeyExclusive option used for registering the Carbon hot keys.

In the exclusive mode the RegisterEventHotKey call will refuse to register a hotkey that already exists. We have to handle that case somehow, currently we just crash. But it’s a hard case to handle in the UI, because Carbon won’t tell us which app registered the hotkey before us. (What should we tell the user? Just saying that the shortcut is already used is dumb.)

@shpakovski, what do you think about dropping the exclusive mode? Then the hotkey registration won’t fail even if the shortcut is already registered. And the worst that can happen is that two apps will respond to the same shortcut, which is a case that’s pretty easy to understand and fix for a user.

shpakovski commented 9 years ago

I agree, I would expect that both shortcuts do work rather than have an alert without clear meaning and the hint which app uses the hockey already.