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 1de283fb956b7dc53d180ed36ec06e1e07d4ae91..3f2eb7ce64c687b69f0be1a58600f102a4ea0bf1 100644 |
| --- a/ui/views/cocoa/native_widget_mac_nswindow.mm |
| +++ b/ui/views/cocoa/native_widget_mac_nswindow.mm |
| @@ -25,6 +25,8 @@ |
| base::scoped_nsobject<CommandDispatcher> commandDispatcher_; |
| } |
| +@synthesize commandHandler; |
|
tapted
2015/09/04 02:56:24
With this approach (i.e. assign not retain), I thi
jackhou1
2015/09/04 06:13:59
Changed to retain.
|
| + |
| - (instancetype)initWithContentRect:(NSRect)contentRect |
| styleMask:(NSUInteger)windowStyle |
| backing:(NSBackingStoreType)bufferingType |
| @@ -168,4 +170,29 @@ |
| return [super performKeyEquivalent:event]; |
| } |
| +- (void)commandDispatch:(id)sender { |
| + [[self commandHandler] commandDispatch:sender window:self]; |
| +} |
| + |
| +- (void)commandDispatchUsingKeyModifiers:(id)sender { |
| + [[self commandHandler] commandDispatchUsingKeyModifiers:sender window:self]; |
| +} |
| + |
| +// NSWindow overrides (NSUserInterfaceItemValidations implementation) |
| + |
| +- (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item { |
| + // Since this class implements these selectors, |super| will always say they |
|
tapted
2015/09/04 02:56:24
Then perhaps this logic can move into commandDispa
jackhou1
2015/09/04 06:13:59
Ah, I agree sharing this logic would be good. But
|
| + // are enabled. Only use [super] to validate other selectors. If there is no |
| + // command handler, defer to AppController. |
| + if ([item action] == @selector(commandDispatch:) || |
| + [item action] == @selector(commandDispatchUsingKeyModifiers:)) { |
| + return |
| + [self commandHandler] |
| + ? [[self commandHandler] validateUserInterfaceItem:item window:self] |
| + : [[NSApp delegate] validateUserInterfaceItem:item]; |
| + } |
| + |
| + return [super validateUserInterfaceItem:item]; |
| +} |
| + |
| @end |