2016-06-17 17:57:28 +00:00
|
|
|
// Copyright (c) 2016 GitHub, Inc.
|
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2019-06-19 20:46:59 +00:00
|
|
|
#include "shell/browser/ui/cocoa/event_dispatching_window.h"
|
2016-06-17 17:57:28 +00:00
|
|
|
|
|
|
|
@implementation EventDispatchingWindow
|
|
|
|
|
|
|
|
- (void)sendEvent:(NSEvent*)event {
|
|
|
|
if (!redispatchingEvent_)
|
|
|
|
[super sendEvent:event];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)performKeyEquivalent:(NSEvent*)event {
|
|
|
|
if (redispatchingEvent_)
|
|
|
|
return NO;
|
|
|
|
else
|
|
|
|
return [super performKeyEquivalent:event];
|
2018-04-20 18:47:04 +00:00
|
|
|
}
|
2016-06-17 17:57:28 +00:00
|
|
|
|
|
|
|
- (void)redispatchKeyEvent:(NSEvent*)event {
|
|
|
|
NSEventType eventType = [event type];
|
2022-06-01 06:12:47 +00:00
|
|
|
if (eventType != NSEventTypeKeyDown && eventType != NSEventTypeKeyUp &&
|
|
|
|
eventType != NSEventTypeFlagsChanged) {
|
2016-06-17 17:57:28 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Redispatch the event.
|
|
|
|
redispatchingEvent_ = YES;
|
|
|
|
[NSApp sendEvent:event];
|
|
|
|
redispatchingEvent_ = NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|