aboutsummaryrefslogtreecommitdiffstats
path: root/Framework/MASShortcutBinder.m
AgeCommit message (Collapse)Author
2015-08-09FixRoman Sokolov
Fix problem: Set hotkey [TheSameHOTKEY], then mousedown on delete button, then set hotkey again [TheSameHOTKEY], then this hotkey do not work.
2015-03-05Removed support for dots and spaces in user defaults keys (#64).Tomáš Znamenáček
I could find no way to make the feature work, so I have pulled it from the code. I have also inserted asserts to warn library users who would attempt to use illegal characters in user defaults keys in the future. In short, you want your user defaults keys to be something identifier-like.
2015-03-05Fix a problem with defaults keys with dot symbols (#64).Tomáš Znamenáček
2015-01-07Added a shared binder instance singleton.Tomáš Znamenáček
This adds a really simple API to set up some bindings without having to keep a binder instance around by hand. If somebody wants to, it’s not a problem to allocate a separate instance and have precise control over its lifetime.
2015-01-07Added a convenience call to register default shortcuts.Tomáš Znamenáček
2015-01-07Binding options can now be customized for MASShortcutBinder.Tomáš Znamenáček
This makes it possible to customize the way the shortcuts are stored in user defaults. The default options call for the keyed archiver transformer, deserializing the shortcuts from NSData.
2015-01-07Turned MASShortcutMonitor into a singleton.Tomáš Znamenáček
There can only be one Carbon event handler, so it doesn’t make sense to create multiple instances of the shortcut monitor.
2015-01-07Refactored the shortcut dispatcher and bindings to user defaults.Tomáš Znamenáček
This is a big change that was hard to split into smaller commits. There’s now a new class to bind shortcuts to actions, a new class to bind user defaults’ keys to actions, and a new way to associate user defaults with the recorder control (MASShortcutView). I have also updated the demo app to go with the changes. The new class to associate shortcuts with actions is called MASShortcutMonitor. It wraps the Carbon hotkey magic and offers a simple interface to add a shortcut along with a block that should be run when the shortcut is pressed. It’s the lowest-level interface. Since the usual requirement is to store the shortcuts into user defaults, there’s also a higher-level interface offered by the MASShortcutBinder class. That takes a defaults key and associates it with a block. When the shortcut stored under the defaults key changes, the binder automatically switches to the new shortcut. The class is a wrapper built atop of the previous one, the MASShortcutMonitor – it simply adds, updates and removes shortcuts as the user defaults change. I have removed the special user defaults integration code from the recorder control (MASShortcutView) and replaced it with a small Cocoa Bindings shim. This means that in order to keep the recorder control in sync with the defaults you just have to call the usual bind:toObject:withKeyPath:options: method, like this: [_shortcutView bind:MASShortcutBinding toObject:[NSUserDefaultsController sharedUserDefaultsController] withKeyPath[@"values.ExampleDefaultsKey" options:@{NSValueTransformerNameBindingOption:NSKeyedUnarchiveFromDataTransformerName}]; That’s more verbose than the previous solution, but it’s much cleaner and can be swept under a convenience call if needed. I might also add a dictionaryValue property later that would make it possible to bind the value to user defaults directly, without a transformer, and would enable backward compatibility with Shortcut Recorder.