diff options
| author | Tomáš Znamenáček | 2015-01-08 12:00:53 +0100 |
|---|---|---|
| committer | Tomáš Znamenáček | 2015-01-08 12:00:53 +0100 |
| commit | 9b919cba51e4cd11b0c4424930d6c18a1baec73c (patch) | |
| tree | a8107774609d5f4263f7b79749d93e6c6ff2642d /Framework/MASShortcut.h | |
| parent | a3a459b4e4e47bf18dccd5dc7f315389346e3d6c (diff) | |
| parent | ea69d5939511f61a7082ba1e8ff46d247862a3fa (diff) | |
| download | MASShortcut-9b919cba51e4cd11b0c4424930d6c18a1baec73c.tar.bz2 | |
Merge pull request #53 from zoul/2.0-candidate
Thank you very much!
Diffstat (limited to 'Framework/MASShortcut.h')
| -rw-r--r-- | Framework/MASShortcut.h | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/Framework/MASShortcut.h b/Framework/MASShortcut.h new file mode 100644 index 0000000..3e1bedf --- /dev/null +++ b/Framework/MASShortcut.h @@ -0,0 +1,70 @@ +#import "MASKeyCodes.h" + +/** + @brief A model class to hold a key combination. + + This class just represents a combination of keys. It does not care if + the combination is valid or can be used as a hotkey, it doesn’t watch + the input system for the shortcut appearance, nor it does access user + defaults. +*/ +@interface MASShortcut : NSObject <NSSecureCoding, NSCopying> + +/** + @brief The virtual key code for the keyboard key. + + @Hardware independent, same as in NSEvent. Events.h in the HIToolbox + framework for a complete list, or Command-click this symbol: kVK_ANSI_A. +*/ +@property (nonatomic, readonly) NSUInteger keyCode; + +/** + @brief Cocoa keyboard modifier flags. + + Same as in NSEvent: NSCommandKeyMask, NSAlternateKeyMask, etc. +*/ +@property (nonatomic, readonly) NSUInteger modifierFlags; + +/** + @brief Same as @p keyCode, just a different type. +*/ +@property (nonatomic, readonly) UInt32 carbonKeyCode; + +/** + @brief Carbon modifier flags. + + A bit sum of @p cmdKey, @p optionKey, etc. +*/ +@property (nonatomic, readonly) UInt32 carbonFlags; + +/** + @brief A string representing the “key” part of a shortcut, like the “5” in “⌘5”. +*/ +@property (nonatomic, readonly) NSString *keyCodeString; + +/** + @brief A key-code string used in key equivalent matching. + + For precise meaning of “key equivalents” see the @p keyEquivalent + property of @p NSMenuItem. Here the string is used to support shortcut + validation (“is the shortcut already taken in this menu?”) and + for display in @p NSMenu. +*/ +@property (nonatomic, readonly) NSString *keyCodeStringForKeyEquivalent; + +/** + @brief A string representing the shortcut modifiers, like the “⌘” in “⌘5”. +*/ +@property (nonatomic, readonly) NSString *modifierFlagsString; + +- (instancetype)initWithKeyCode:(NSUInteger)code modifierFlags:(NSUInteger)flags; ++ (instancetype)shortcutWithKeyCode:(NSUInteger)code modifierFlags:(NSUInteger)flags; + +/** + @brief Creates a new shortcut from an NSEvent object. + + This is just a convenience initializer that reads the key code and modifiers from an NSEvent. +*/ ++ (instancetype)shortcutWithEvent:(NSEvent *)anEvent; + +@end |
