| Age | Commit message (Collapse) | Author |
|
Signed-off-by: Tony Arnold <tony@thecocoabots.com>
|
|
Fixes #76. I considered putting the #pragma just around the particular
compare line, but I think having it around the whole block is more readable
and there’s little chance of having some legitimate warnings silenced.
|
|
|
|
|
|
Tab key must pass through. This is important if you want to do keyboard navigation through this control.
|
|
|
|
The NSAccessibilityPriorityKey symbol was only introduced in 10.9,
so that we have to check for its availability before using it, otherwise
we get a SIGSEGV.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.
|
|
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.
|
|
|
|
The longer message text was used as the alert title.
|
|
|
|
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.
|
|
|
|
The “appearance” property didn’t play nice with auto-synthesizing,
not really sure why.
|
|
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.
|
|
It was never used and the recording can already be cancelled by Esc.
|
|
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.
|
|
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.
|
|
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.
|