aboutsummaryrefslogtreecommitdiffstats
path: root/Framework
diff options
context:
space:
mode:
authorTomáš Znamenáček2016-10-28 14:40:32 +0200
committerTomáš Znamenáček2016-10-28 14:40:32 +0200
commitf12ed861b095d0734173948594202e25ee7e926d (patch)
tree70529b576a710a13fe84fd591328c9de6b9bbc80 /Framework
parentbf4329178d3982f25be96ff3156477349e6bc25d (diff)
downloadMASShortcut-f12ed861b095d0734173948594202e25ee7e926d.tar.bz2
Use modern key mask constants instead of the ones deprecated in 10.12
See #99 for details.
Diffstat (limited to 'Framework')
-rw-r--r--Framework/MASKeyCodes.h11
-rw-r--r--Framework/MASKeyMasks.h16
2 files changed, 22 insertions, 5 deletions
diff --git a/Framework/MASKeyCodes.h b/Framework/MASKeyCodes.h
index 989c942..b6b53fe 100644
--- a/Framework/MASKeyCodes.h
+++ b/Framework/MASKeyCodes.h
@@ -1,5 +1,6 @@
#import <Carbon/Carbon.h>
#import <AppKit/AppKit.h>
+#import "MASKeyCodes.h"
// These glyphs are missed in Carbon.h
enum {
@@ -30,14 +31,14 @@ NS_INLINE NSString* NSStringFromMASKeyCode(unsigned short ch)
NS_INLINE NSUInteger MASPickCocoaModifiers(NSUInteger flags)
{
- return (flags & (NSControlKeyMask | NSShiftKeyMask | NSAlternateKeyMask | NSCommandKeyMask));
+ return (flags & (NSEventModifierFlagControl | NSEventModifierFlagShift | NSEventModifierFlagOption | NSEventModifierFlagCommand));
}
NS_INLINE UInt32 MASCarbonModifiersFromCocoaModifiers(NSUInteger cocoaFlags)
{
return
- (cocoaFlags & NSCommandKeyMask ? cmdKey : 0)
- | (cocoaFlags & NSAlternateKeyMask ? optionKey : 0)
- | (cocoaFlags & NSControlKeyMask ? controlKey : 0)
- | (cocoaFlags & NSShiftKeyMask ? shiftKey : 0);
+ (cocoaFlags & NSEventModifierFlagCommand ? cmdKey : 0)
+ | (cocoaFlags & NSEventModifierFlagOption ? optionKey : 0)
+ | (cocoaFlags & NSEventModifierFlagControl ? controlKey : 0)
+ | (cocoaFlags & NSEventModifierFlagShift ? shiftKey : 0);
}
diff --git a/Framework/MASKeyMasks.h b/Framework/MASKeyMasks.h
new file mode 100644
index 0000000..1c3a0b9
--- /dev/null
+++ b/Framework/MASKeyMasks.h
@@ -0,0 +1,16 @@
+// https://github.com/shpakovski/MASShortcut/issues/99
+//
+// Long story short: NSControlKeyMask and friends were replaced with NSEventModifierFlagControl
+// and similar in macOS Sierra. The project builds fine & clean, but including MASShortcut in
+// a project with deployment target set to 10.12 results in several deprecation warnings because
+// of the control masks. Simply replacing the old symbols with the new ones isn’t an option,
+// since it breaks the build on older SDKs – in Travis, for example.
+//
+// It should be safe to remove this whole thing once the 10.12 SDK is ubiquitous.
+//
+#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12
+#define NSEventModifierFlagCommand NSCommandKeyMask
+#define NSEventModifierFlagControl NSControlKeyMask
+#define NSEventModifierFlagOption NSAlternateKeyMask
+#define NSEventModifierFlagShift NSShiftKeyMask
+#endif