Redispatch key events to handle native shortcuts
This commit is contained in:
parent
d37a120a6a
commit
df726d0f41
1 changed files with 39 additions and 1 deletions
|
@ -10,6 +10,44 @@
|
||||||
|
|
||||||
using namespace brightray;
|
using namespace brightray;
|
||||||
|
|
||||||
|
@interface EventDispatchingWindow : UnderlayOpenGLHostingWindow {
|
||||||
|
@private
|
||||||
|
BOOL redispatchingEvent_;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)redispatchKeyEvent:(NSEvent*)event;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation EventDispatchingWindow
|
||||||
|
|
||||||
|
- (void)sendEvent:(NSEvent*)event {
|
||||||
|
if (!redispatchingEvent_)
|
||||||
|
[super sendEvent:event];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)performKeyEquivalent:(NSEvent*)event {
|
||||||
|
if (redispatchingEvent_)
|
||||||
|
return NO;
|
||||||
|
else
|
||||||
|
return [super performKeyEquivalent:event];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)redispatchKeyEvent:(NSEvent*)event {
|
||||||
|
NSEventType eventType = [event type];
|
||||||
|
if (eventType != NSKeyDown && eventType != NSKeyUp &&
|
||||||
|
eventType != NSFlagsChanged) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Redispatch the event.
|
||||||
|
redispatchingEvent_ = YES;
|
||||||
|
[NSApp sendEvent:event];
|
||||||
|
redispatchingEvent_ = NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
@implementation BRYInspectableWebContentsView
|
@implementation BRYInspectableWebContentsView
|
||||||
|
|
||||||
- (instancetype)initWithInspectableWebContentsViewMac:(InspectableWebContentsViewMac*)view {
|
- (instancetype)initWithInspectableWebContentsViewMac:(InspectableWebContentsViewMac*)view {
|
||||||
|
@ -132,7 +170,7 @@ using namespace brightray;
|
||||||
NSMiniaturizableWindowMask | NSResizableWindowMask |
|
NSMiniaturizableWindowMask | NSResizableWindowMask |
|
||||||
NSTexturedBackgroundWindowMask |
|
NSTexturedBackgroundWindowMask |
|
||||||
NSUnifiedTitleAndToolbarWindowMask;
|
NSUnifiedTitleAndToolbarWindowMask;
|
||||||
devtools_window_.reset([[UnderlayOpenGLHostingWindow alloc]
|
devtools_window_.reset([[EventDispatchingWindow alloc]
|
||||||
initWithContentRect:NSMakeRect(0, 0, 800, 600)
|
initWithContentRect:NSMakeRect(0, 0, 800, 600)
|
||||||
styleMask:styleMask
|
styleMask:styleMask
|
||||||
backing:NSBackingStoreBuffered
|
backing:NSBackingStoreBuffered
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue