Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: app/menus/accelerator_cocoa.h

Issue 2800019: [Mac] Give the Wrench menu keyboard shortcuts. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Split out keymap into new file Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2010 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.
4
5 #ifndef APP_MENUS_ACCELERATOR_COCOA_H_
6 #define APP_MENUS_ACCELERATOR_COCOA_H_
7
8 #include <Foundation/Foundation.h>
9
10 #include "app/menus/accelerator.h"
11 #include "base/scoped_nsobject.h"
12
13 namespace menus {
14
15 // This is a subclass of the cross-platform Accelerator, but with more direct
16 // support for Cocoa key equivalents. Note that the typical use case for this
17 // class is to initialize it with a string literal, which is why it sends
18 // |-copy| to the |key_code| paramater in the constructor.
19 class AcceleratorCocoa : public Accelerator {
20 public:
21 AcceleratorCocoa(NSString* key_code, NSUInteger mask)
22 : Accelerator(base::VKEY_UNKNOWN, mask),
23 characters_([key_code copy]) {
24 }
25
26 AcceleratorCocoa(const AcceleratorCocoa& accelerator)
27 : Accelerator(accelerator) {
28 characters_.reset([accelerator.characters_ copy]);
29 }
30
31 AcceleratorCocoa() : Accelerator() {}
pink (ping after 24hrs) 2010/06/21 19:21:56 not sure this is necessary, but can't hurt.
32 virtual ~AcceleratorCocoa() {}
33
34 AcceleratorCocoa& operator=(const AcceleratorCocoa& accelerator) {
35 if (this != &accelerator) {
36 *static_cast<Accelerator*>(this) = accelerator;
37 characters_.reset([accelerator.characters_ copy]);
38 }
39 return *this;
40 }
41
42 bool operator ==(const AcceleratorCocoa& rhs) const {
pink (ping after 24hrs) 2010/06/21 19:21:56 no space after "operator"?
43 return [characters_ isEqualToString:rhs.characters_.get()] &&
44 (modifiers_ == rhs.modifiers_);
45 }
46
47 NSString* characters() const {
48 return characters_.get();
49 }
50
51 private:
52 // String of characters for the key equivalent.
53 scoped_nsobject<NSString> characters_;
54 };
55
56 } // namespace menus
57
58 #endif // APP_MENUS_ACCELERATOR_COCOA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698