| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 cr.define('cr.ui', function() { | 5 cr.define('cr.ui', function() { |
| 6 | 6 |
| 7 const Menu = cr.ui.Menu; | 7 const Menu = cr.ui.Menu; |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * Handles context menus. | 10 * Handles context menus. |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 case 'mousedown': | 125 case 'mousedown': |
| 126 if (!this.menu.contains(e.target)) | 126 if (!this.menu.contains(e.target)) |
| 127 this.hideMenu(); | 127 this.hideMenu(); |
| 128 else | 128 else |
| 129 e.preventDefault(); | 129 e.preventDefault(); |
| 130 break; | 130 break; |
| 131 case 'keydown': | 131 case 'keydown': |
| 132 // keyIdentifier does not report 'Esc' correctly | 132 // keyIdentifier does not report 'Esc' correctly |
| 133 if (e.keyCode == 27 /* Esc */) { | 133 if (e.keyCode == 27 /* Esc */) { |
| 134 this.hideMenu(); | 134 this.hideMenu(); |
| 135 e.stopPropagation(); |
| 136 e.preventDefault(); |
| 135 | 137 |
| 136 // If the menu is visible we let it handle all the keyboard events. | 138 // If the menu is visible we let it handle all the keyboard events. |
| 137 } else if (this.menu) { | 139 } else if (this.menu) { |
| 138 this.menu.handleKeyDown(e); | 140 this.menu.handleKeyDown(e); |
| 139 e.preventDefault(); | 141 e.preventDefault(); |
| 140 e.stopPropagation(); | 142 e.stopPropagation(); |
| 141 } | 143 } |
| 142 break; | 144 break; |
| 143 | 145 |
| 144 case 'activate': | 146 case 'activate': |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 * The singleton context menu handler. | 218 * The singleton context menu handler. |
| 217 * @type {!ContextMenuHandler} | 219 * @type {!ContextMenuHandler} |
| 218 */ | 220 */ |
| 219 var contextMenuHandler = new ContextMenuHandler; | 221 var contextMenuHandler = new ContextMenuHandler; |
| 220 | 222 |
| 221 // Export | 223 // Export |
| 222 return { | 224 return { |
| 223 contextMenuHandler: contextMenuHandler | 225 contextMenuHandler: contextMenuHandler |
| 224 }; | 226 }; |
| 225 }); | 227 }); |
| OLD | NEW |