Chromium Code Reviews| Index: ui/views/cocoa/native_widget_mac_nswindow.mm |
| diff --git a/ui/views/cocoa/native_widget_mac_nswindow.mm b/ui/views/cocoa/native_widget_mac_nswindow.mm |
| index 8799ee15a35550cea141390c6a4f51f9d5de6c6c..06f695d78a00539e37663ee662ab25f3987a2c47 100644 |
| --- a/ui/views/cocoa/native_widget_mac_nswindow.mm |
| +++ b/ui/views/cocoa/native_widget_mac_nswindow.mm |
| @@ -22,6 +22,19 @@ |
| @implementation NativeWidgetMacNSWindow |
| +- (instancetype)initWithContentRect:(NSRect)contentRect |
| + styleMask:(NSUInteger)windowStyle |
| + backing:(NSBackingStoreType)bufferingType |
| + defer:(BOOL)deferCreation { |
| + if ((self = [super initWithContentRect:contentRect |
| + styleMask:windowStyle |
| + backing:bufferingType |
| + defer:deferCreation])) { |
| + commandDispatcher_.reset([[CommandDispatcher alloc] initWithOwner:self]); |
| + } |
| + return self; |
| +} |
| + |
| - (ViewsNSWindowDelegate*)viewsNSWindowDelegate { |
| return base::mac::ObjCCastStrict<ViewsNSWindowDelegate>([self delegate]); |
| } |
| @@ -64,6 +77,10 @@ |
| // menu while it is active, and while still allowing any native subview to |
| // retain firstResponder status. |
| - (void)sendEvent:(NSEvent*)event { |
| + // Let CommandDispatcher check if this is a redispatched event. |
| + if ([commandDispatcher_ preSendEvent:event]) |
| + return; |
| + |
| NSEventType type = [event type]; |
| if ((type != NSKeyDown && type != NSKeyUp) || ![self hasViewsMenuActive]) { |
| [super sendEvent:event]; |
| @@ -104,6 +121,10 @@ |
| // NSResponder implementation. |
| +- (BOOL)performKeyEquivalent:(NSEvent*)event { |
| + return [commandDispatcher_ performKeyEquivalent:event]; |
| +} |
| + |
| - (void)cursorUpdate:(NSEvent*)theEvent { |
| // The cursor provided by the delegate should only be applied within the |
| // content area. This is because we rely on the contentView to track the |
| @@ -124,4 +145,20 @@ |
| [super cursorUpdate:theEvent]; |
| } |
| +// CommandDispatcher implementation. |
| + |
| +- (BOOL)redispatchKeyEvent:(NSEvent*)event { |
| + return [commandDispatcher_ redispatchKeyEvent:event]; |
| +} |
| + |
| +- (BOOL)defaultPerformKeyEquivalent:(NSEvent*)event { |
| + return [super performKeyEquivalent:event]; |
| +} |
| + |
| +// Public methods. |
|
tapted
2015/08/26 06:46:54
nit: new methods before overrides (in the follow-u
jackhou1
2015/08/26 07:38:17
Done.
|
| + |
| +- (void)setCommandDispatcherDelegate:(id<CommandDispatcherDelegate>)delegate { |
| + [commandDispatcher_ setDelegate:delegate]; |
| +} |
| + |
| @end |