Change global shortcuts on Mac to be eaten.
Update issue #722 Fixed on Mac.
This commit is contained in:
parent
c65a687678
commit
4570d891f2
@ -44,7 +44,7 @@ protected:
|
|||||||
void DoUnregister();
|
void DoUnregister();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void KeyPressed(const QKeySequence& sequence);
|
bool KeyPressed(const QKeySequence& sequence);
|
||||||
|
|
||||||
QMap<QKeySequence, QAction*> shortcuts_;
|
QMap<QKeySequence, QAction*> shortcuts_;
|
||||||
|
|
||||||
|
@ -49,8 +49,8 @@ class MacGlobalShortcutBackendPrivate : boost::noncopyable {
|
|||||||
}];
|
}];
|
||||||
local_monitor_ = [NSEvent addLocalMonitorForEventsMatchingMask:NSKeyDownMask
|
local_monitor_ = [NSEvent addLocalMonitorForEventsMatchingMask:NSKeyDownMask
|
||||||
handler:^(NSEvent* event) {
|
handler:^(NSEvent* event) {
|
||||||
HandleKeyEvent(event);
|
// Filter event if we handle it as a global shortcut.
|
||||||
return event;
|
return HandleKeyEvent(event) ? nil : event;
|
||||||
}];
|
}];
|
||||||
return true;
|
return true;
|
||||||
#else
|
#else
|
||||||
@ -108,9 +108,9 @@ class MacGlobalShortcutBackendPrivate : boost::noncopyable {
|
|||||||
return QKeySequence(key);
|
return QKeySequence(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandleKeyEvent(NSEvent* event) {
|
bool HandleKeyEvent(NSEvent* event) {
|
||||||
QKeySequence sequence = GetSequence(event);
|
QKeySequence sequence = GetSequence(event);
|
||||||
backend_->KeyPressed(sequence);
|
return backend_->KeyPressed(sequence);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int MapFunctionKey(int keycode) {
|
static int MapFunctionKey(int keycode) {
|
||||||
@ -218,14 +218,16 @@ void MacGlobalShortcutBackend::MacMediaKeyPressed(int key) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacGlobalShortcutBackend::KeyPressed(const QKeySequence& sequence) {
|
bool MacGlobalShortcutBackend::KeyPressed(const QKeySequence& sequence) {
|
||||||
if (sequence.isEmpty()) {
|
if (sequence.isEmpty()) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
QAction* action = shortcuts_[sequence];
|
QAction* action = shortcuts_[sequence];
|
||||||
if (action) {
|
if (action) {
|
||||||
action->trigger();
|
action->trigger();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MacGlobalShortcutBackend::IsAccessibilityEnabled() const {
|
bool MacGlobalShortcutBackend::IsAccessibilityEnabled() const {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user