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

Side by Side Diff: chrome/browser/cocoa/menu_controller.mm

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
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "chrome/browser/cocoa/menu_controller.h" 5 #import "chrome/browser/cocoa/menu_controller.h"
6 6
7 #include "app/l10n_util_mac.h" 7 #include "app/l10n_util_mac.h"
8 #include "app/menus/accelerator_cocoa.h"
8 #include "app/menus/simple_menu_model.h" 9 #include "app/menus/simple_menu_model.h"
9 #include "base/logging.h" 10 #include "base/logging.h"
10 #include "base/sys_string_conversions.h" 11 #include "base/sys_string_conversions.h"
11 12
12 @interface MenuController(Private) 13 @interface MenuController(Private)
13 - (NSMenu*)menuFromModel:(menus::MenuModel*)model; 14 - (NSMenu*)menuFromModel:(menus::MenuModel*)model;
14 - (void)addSeparatorToMenu:(NSMenu*)menu 15 - (void)addSeparatorToMenu:(NSMenu*)menu
15 atIndex:(int)index; 16 atIndex:(int)index;
16 - (void)addItemToMenu:(NSMenu*)menu 17 - (void)addItemToMenu:(NSMenu*)menu
17 atIndex:(int)index 18 atIndex:(int)index
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 } else { 96 } else {
96 // The MenuModel works on indexes so we can't just set the command id as the 97 // The MenuModel works on indexes so we can't just set the command id as the
97 // tag like we do in other menus. Also set the represented object to be 98 // tag like we do in other menus. Also set the represented object to be
98 // the model so hierarchical menus check the correct index in the correct 99 // the model so hierarchical menus check the correct index in the correct
99 // model. Setting the target to |self| allows this class to participate 100 // model. Setting the target to |self| allows this class to participate
100 // in validation of the menu items. 101 // in validation of the menu items.
101 [item setTag:modelIndex]; 102 [item setTag:modelIndex];
102 [item setTarget:self]; 103 [item setTarget:self];
103 NSValue* modelObject = [NSValue valueWithPointer:model]; 104 NSValue* modelObject = [NSValue valueWithPointer:model];
104 [item setRepresentedObject:modelObject]; // Retains |modelObject|. 105 [item setRepresentedObject:modelObject]; // Retains |modelObject|.
106 menus::AcceleratorCocoa accelerator;
107 if (model->GetAcceleratorAt(modelIndex, &accelerator)) {
108 [item setKeyEquivalent:accelerator.characters()];
109 [item setKeyEquivalentModifierMask:accelerator.modifiers()];
110 }
105 } 111 }
106 [menu insertItem:item atIndex:index]; 112 [menu insertItem:item atIndex:index];
107 } 113 }
108 114
109 // Called before the menu is to be displayed to update the state (enabled, 115 // Called before the menu is to be displayed to update the state (enabled,
110 // radio, etc) of each item in the menu. Also will update the title if 116 // radio, etc) of each item in the menu. Also will update the title if
111 // the item is marked as "dynamic". 117 // the item is marked as "dynamic".
112 - (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item { 118 - (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item {
113 SEL action = [item action]; 119 SEL action = [item action];
114 if (action != @selector(itemSelected:)) 120 if (action != @selector(itemSelected:))
(...skipping 28 matching lines...) Expand all
143 DCHECK(model); 149 DCHECK(model);
144 if (model) 150 if (model)
145 model->ActivatedAt(modelIndex); 151 model->ActivatedAt(modelIndex);
146 } 152 }
147 153
148 - (NSMenu*)menu { 154 - (NSMenu*)menu {
149 return menu_.get(); 155 return menu_.get();
150 } 156 }
151 157
152 @end 158 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698