diff options
| author | Tomáš Znamenáček | 2014-08-05 15:34:46 +0200 | 
|---|---|---|
| committer | Tomáš Znamenáček | 2015-01-07 15:05:12 +0100 | 
| commit | 1c801726d35e56d3bbf4a33279213bc60935c244 (patch) | |
| tree | fad9932f1542e10daa6a1d27c1e34fe8157577a4 /Framework/MASKeyCodes.h | |
| parent | 88392d1a6963cca5009b9b0c20b054ad9e911b6c (diff) | |
| download | MASShortcut-1c801726d35e56d3bbf4a33279213bc60935c244.tar.bz2 | |
Converted keycode macros to plain functions.
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.
Diffstat (limited to 'Framework/MASKeyCodes.h')
| -rw-r--r-- | Framework/MASKeyCodes.h | 19 | 
1 files changed, 19 insertions, 0 deletions
| diff --git a/Framework/MASKeyCodes.h b/Framework/MASKeyCodes.h index 69b2a97..9fb5b02 100644 --- a/Framework/MASKeyCodes.h +++ b/Framework/MASKeyCodes.h @@ -21,3 +21,22 @@ enum {  	kMASShortcutGlyphNorthwestArrow = 0x2196,  	kMASShortcutGlyphSoutheastArrow = 0x2198,  } MASShortcutGlyph; + +NS_INLINE NSString* NSStringFromMASKeyCode(unsigned short ch) +{ +    return [NSString stringWithFormat:@"%C", ch]; +} + +NS_INLINE NSUInteger MASPickCocoaModifiers(NSUInteger flags) +{ +    return (flags & (NSControlKeyMask | NSShiftKeyMask | NSAlternateKeyMask | NSCommandKeyMask)); +} + +NS_INLINE UInt32 MASCarbonModifiersFromCocoaModifiers(NSUInteger cocoaFlags) +{ +    return +          (cocoaFlags & NSCommandKeyMask ? cmdKey : 0) +        | (cocoaFlags & NSAlternateKeyMask ? optionKey : 0) +        | (cocoaFlags & NSControlKeyMask ? controlKey : 0) +        | (cocoaFlags & NSShiftKeyMask ? shiftKey : 0); +} | 
