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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: app/menus/accelerator_cocoa.h
diff --git a/app/menus/accelerator_cocoa.h b/app/menus/accelerator_cocoa.h
new file mode 100644
index 0000000000000000000000000000000000000000..15c76eefc85045929c20bd7902a535718412690b
--- /dev/null
+++ b/app/menus/accelerator_cocoa.h
@@ -0,0 +1,58 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef APP_MENUS_ACCELERATOR_COCOA_H_
+#define APP_MENUS_ACCELERATOR_COCOA_H_
+
+#include <Foundation/Foundation.h>
+
+#include "app/menus/accelerator.h"
+#include "base/scoped_nsobject.h"
+
+namespace menus {
+
+// This is a subclass of the cross-platform Accelerator, but with more direct
+// support for Cocoa key equivalents. Note that the typical use case for this
+// class is to initialize it with a string literal, which is why it sends
+// |-copy| to the |key_code| paramater in the constructor.
+class AcceleratorCocoa : public Accelerator {
+ public:
+ AcceleratorCocoa(NSString* key_code, NSUInteger mask)
+ : Accelerator(base::VKEY_UNKNOWN, mask),
+ characters_([key_code copy]) {
+ }
+
+ AcceleratorCocoa(const AcceleratorCocoa& accelerator)
+ : Accelerator(accelerator) {
+ characters_.reset([accelerator.characters_ copy]);
+ }
+
+ AcceleratorCocoa() : Accelerator() {}
pink (ping after 24hrs) 2010/06/21 19:21:56 not sure this is necessary, but can't hurt.
+ virtual ~AcceleratorCocoa() {}
+
+ AcceleratorCocoa& operator=(const AcceleratorCocoa& accelerator) {
+ if (this != &accelerator) {
+ *static_cast<Accelerator*>(this) = accelerator;
+ characters_.reset([accelerator.characters_ copy]);
+ }
+ return *this;
+ }
+
+ bool operator ==(const AcceleratorCocoa& rhs) const {
pink (ping after 24hrs) 2010/06/21 19:21:56 no space after "operator"?
+ return [characters_ isEqualToString:rhs.characters_.get()] &&
+ (modifiers_ == rhs.modifiers_);
+ }
+
+ NSString* characters() const {
+ return characters_.get();
+ }
+
+ private:
+ // String of characters for the key equivalent.
+ scoped_nsobject<NSString> characters_;
+};
+
+} // namespace menus
+
+#endif // APP_MENUS_ACCELERATOR_COCOA_H_

Powered by Google App Engine
This is Rietveld 408576698