aboutsummaryrefslogtreecommitdiffstats
path: root/Framework
AgeCommit message (Collapse)Author
2015-01-14Added test for hotkeys and shortcut monitor.Tomáš Znamenáček
2015-01-14Updating to current master.Tomáš Znamenáček
2015-01-14Use the clear glyph instead of backspace for clearing a shortcut.Tomáš Znamenáček
The recording control used to display the backspace glyph (U+232B) on the button that clears the shortcut. That’s a bit confusing, since the same backspace glyph can also appear inside the control, representing the recorded shortcut. The clear glyph (U+2715, diagonal cross) seems like a better fit – it’s already used in similar context throughout the Apple UIs like search bars.
2015-01-14Updated headerdoc markup for MASShortcutView+Bindings.Tomáš Znamenáček
2015-01-13Merge branch 'master' into legacy-osx-support.Tomáš Znamenáček
Conflicts: CHANGES
2015-01-13Changed headerdoc markup to work better with CocoaDocs (closes #55).Tomáš Znamenáček
2015-01-12Non-exclusive hotkey registration (#56).Tomáš Znamenáček
2015-01-12Added support for older OS X releases back to 10.6 included.Tomáš Znamenáček
Apart from turning off Auto Layout for the Demo project, the only thing remaining was several __weak qualifiers to prevent retain cycles in blocks. I have replaced them with __unsafe_unretained since __weak is not supported on 10.6. There should be no safety concerns here, since we are certain the pointers will remain valid.
2015-01-08MASShortcutMonitor will silently skip nil shortcuts passed to ↵Tomáš Znamenáček
unregisterShortcut:.
2015-01-08Ignore disabled system shortcuts.Tomáš Znamenáček
This was implemented before in 0633545a, but lost during the rebase.
2015-01-08Documented the recording control behaviour and implemented Cmd-W/Q.Tomáš Znamenáček
2015-01-07Updated copyright & versioning info in the framework’s Info.plist.Tomáš Znamenáček
2015-01-07Fixed the alert that pops up when the shortcut is already used.Tomáš Znamenáček
The longer message text was used as the alert title.
2015-01-07Fixed MASShortcutView initialization errors after rebase.Tomáš Znamenáček
2015-01-07Accept Backspace and Delete keys with modifiers as valid shortcuts.Tomáš Znamenáček
When recording a new shortcut using the MASShortcutView control, the user may press Delete or Backspace to clear the current shortcut. In the previous versions the corresponding code branch didn’t test the modifier flags, making it impossible to record shortcuts such as Cmd-Alt-Delete. Now the control should behave as expected, only using “naked” Delete and Backspace keys to clear the shortcut.
2015-01-07Fixed wrong archiver used for MASShortcutView bindings.Tomáš Znamenáček
2015-01-07Added header documentation.Tomáš Znamenáček
2015-01-07Introduced a MASDictionaryTransformerName constant.Tomáš Znamenáček
This makes it easier to set view bindings from within the Interface Builder.
2015-01-07Whitespace fixes.Tomáš Znamenáček
2015-01-07Added a simplified binding API for MASShortcutView.Tomáš Znamenáček
This returns the associatedUserDefaultsKey property used in previous code versions, only the implementation uses less magic.
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-07Better treatment of nil values when storing shortcuts as dictionaries.Tomáš Znamenáček
This makes it possible to make a difference between “shortcut not set, use default” and “shortcut set to none”.
2015-01-07Added a convenience call to register default shortcuts.Tomáš Znamenáček
2015-01-07Added Shortcut.h to the tests prefix header to simplify tests.Tomáš Znamenáček
2015-01-07Added a custom transformer to store shortcuts as dictionaries.Tomáš Znamenáček
The MASDictionaryTransformer class is used to save shortcuts to user defaults (and load them back) using a simple dictionary. The value stored in the user defaults looks like this: $ defaults read com.shpakovski.mac.Demo { MASDemoShortcut = { keyCode = 15; modifierFlags = 1048576; }; … } This storage format has got the distinct advantage of being compatible with the format used by Shortcut Recorder. In order to use it, you have to set proper binding options for MASShortcutBinder and the recorder control (MASShortcutView).
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-07Removed explicit @synthesize and renamed “appearance” to “style”.Tomáš Znamenáček
The “appearance” property didn’t play nice with auto-synthesizing, not really sure why.
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.
2015-01-07Removed one forgotten modifierFlags setter.Tomáš Znamenáček
It’s not needed now the class is effectively immutable.
2015-01-07Implemented equality for shortcut objects.Tomáš Znamenáček
Shortcuts are equal if and only if their key codes and modifier flags are.
2015-01-07Made the keyCode and modifierFlags properties read-only.Tomáš Znamenáček
A shortcut is a good value type, it makes good sense to represent it using an immutable object like NSNumber or NSString.
2015-01-07Implemented NSCopying for MASShortcut.Tomáš Znamenáček
This makes it possible to use shortcuts as collection keys.
2015-01-07Removed -data and shortcutWithData: from MASShortcut.Tomáš Znamenáček
Using NSKeyedUnarchiver and NSKeyedArchiver directly is almost the same amount of typing and it’s much clearer what goes on.
2015-01-07Trivial refactoring.Tomáš Znamenáček
Forgot one `instancetype`, added `static` to NSString constants, removed unneccessary @synthesize directives.
2015-01-07Removed [MASShortcut shouldBypass].Tomáš Znamenáček
It was never used and the recording can already be cancelled by Esc.
2015-01-07Introduced `instancetype` return type where appropriate.Tomáš Znamenáček
2015-01-07Introduced a standalone MASShortcutValidator class to validate shortcuts.Tomáš Znamenáček
It’s a natural simplification of the MASShortcut class. All MASShortcutView objects use a shared validator by default, but can be reconfigured to use a different validator if needed through the shortcutValidator property.
2015-01-07Converted keycode macros to plain functions.Tomáš Znamenáček
Plain functions are less prone to bugs, the compiler understands them better and can offer better error messages, and plain functions can be refactored more easily.
2015-01-07Introduced a separate header file for keycode definitions.Tomáš Znamenáček
2015-01-07Added a unit testing target.Tomáš Znamenáček
2015-01-07Deleted an unneccessary prefix header for the framework target.Tomáš Znamenáček
2015-01-07Created an umbrella header.Tomáš Znamenáček
Now you can just `#import <MASShortcut/Shortcut.h>`.
2015-01-07Repackaged the code as a framework and included the demo.Tomáš Znamenáček
Packaging the code as a framework is mostly just a formality. It doesn’t really change much, it just turns the code into a regular component. What it does change is that the code now has its own Xcode settings, which could make compatibility easier in the long run. Including the demo in the main repository makes it easier to hack on the library, since you can try the changes immediately. It also shows how to bundle the framework into an app that uses it.