Fix deprecated macOS key modifiers

This commit is contained in:
Jonas Kvinge 2019-08-16 22:27:48 +02:00
parent a33e6c03e4
commit 16edc52bae
3 changed files with 7 additions and 7 deletions

View File

@ -392,16 +392,16 @@ QKeySequence KeySequenceFromNSEvent(NSEvent* event) {
}
}
if (modifiers & NSShiftKeyMask) {
if (modifiers & NSEventModifierFlagShift) {
key += Qt::SHIFT;
}
if (modifiers & NSControlKeyMask) {
if (modifiers & NSEventModifierFlagControl) {
key += Qt::META;
}
if (modifiers & NSAlternateKeyMask) {
if (modifiers & NSEventModifierFlagOption) {
key += Qt::ALT;
}
if (modifiers & NSCommandKeyMask) {
if (modifiers & NSEventModifierFlagCommand) {
key += Qt::CTRL;
}

View File

@ -51,10 +51,10 @@ class GlobalShortcutBackendMacOSPrivate : boost::noncopyable {
: global_monitor_(nil), local_monitor_(nil), backend_(backend) {}
bool Register() {
global_monitor_ = [NSEvent addGlobalMonitorForEventsMatchingMask:NSKeyDownMask handler:^(NSEvent* event) {
global_monitor_ = [NSEvent addGlobalMonitorForEventsMatchingMask:NSEventMaskKeyDown handler:^(NSEvent* event) {
HandleKeyEvent(event);
} ];
local_monitor_ = [NSEvent addLocalMonitorForEventsMatchingMask:NSKeyDownMask handler:^(NSEvent* event) {
local_monitor_ = [NSEvent addLocalMonitorForEventsMatchingMask:NSEventMaskKeyDown handler:^(NSEvent* event) {
// Filter event if we handle it as a global shortcut.
return HandleKeyEvent(event) ? nil : event;
} ];

View File

@ -53,7 +53,7 @@ bool GlobalShortcutGrabber::HandleMacEvent(NSEvent* event) {
}
void GlobalShortcutGrabber::SetupMacEventHandler() {
id monitor = [NSEvent addLocalMonitorForEventsMatchingMask: NSKeyDownMask handler:^(NSEvent* event) {
id monitor = [NSEvent addLocalMonitorForEventsMatchingMask: NSEventMaskKeyDown handler:^(NSEvent* event) {
return HandleMacEvent(event) ? event : nil;
}];
wrapper_ = new MacMonitorWrapper(monitor);