1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #import "chrome/browser/ui/cocoa/multi_key_equivalent_button.h"
7 @implementation MultiKeyEquivalentButton
9 - (void)addKeyEquivalent:(KeyEquivalentAndModifierMask)key {
10 extraKeys_.push_back(key);
13 - (BOOL)performKeyEquivalent:(NSEvent*)event {
14 NSWindow* modalWindow = [NSApp modalWindow];
15 NSWindow* window = [self window];
17 if ([self isEnabled] &&
18 (!modalWindow || modalWindow == window || [window worksWhenModal])) {
19 for (size_t index = 0; index < extraKeys_.size(); ++index) {
20 KeyEquivalentAndModifierMask key = extraKeys_[index];
22 [key.charCode isEqualToString:[event charactersIgnoringModifiers]] &&
23 ([event modifierFlags] & key.mask) == key.mask) {
24 [self performClick:self];
30 return [super performKeyEquivalent:event];