OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ui/app_list/cocoa/apps_grid_view_item.h" | 5 #import "ui/app_list/cocoa/apps_grid_view_item.h" |
6 | 6 |
7 #include "base/mac/foundation_util.h" | 7 #include "base/mac/foundation_util.h" |
8 #include "base/mac/mac_util.h" | 8 #include "base/mac/mac_util.h" |
9 #include "base/mac/scoped_nsobject.h" | 9 #include "base/mac/scoped_nsobject.h" |
10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 | 312 |
313 - (app_list::AppListItem*)model { | 313 - (app_list::AppListItem*)model { |
314 return observerBridge_->model(); | 314 return observerBridge_->model(); |
315 } | 315 } |
316 | 316 |
317 - (NSButton*)button { | 317 - (NSButton*)button { |
318 return [[self itemBackgroundView] button]; | 318 return [[self itemBackgroundView] button]; |
319 } | 319 } |
320 | 320 |
321 - (NSMenu*)contextMenu { | 321 - (NSMenu*)contextMenu { |
| 322 // Don't show the menu if button is already held down, e.g. with a left-click. |
| 323 if ([[[self button] cell] isHighlighted]) |
| 324 return nil; |
| 325 |
322 [self setSelected:YES]; | 326 [self setSelected:YES]; |
323 return observerBridge_->GetContextMenu(); | 327 return observerBridge_->GetContextMenu(); |
324 } | 328 } |
325 | 329 |
326 - (NSBitmapImageRep*)dragRepresentationForRestore:(BOOL)isRestore { | 330 - (NSBitmapImageRep*)dragRepresentationForRestore:(BOOL)isRestore { |
327 NSButton* button = [self button]; | 331 NSButton* button = [self button]; |
328 NSView* itemView = [self view]; | 332 NSView* itemView = [self view]; |
329 | 333 |
330 // The snapshot is never drawn as if it was selected. Also remove the cell | 334 // The snapshot is never drawn as if it was selected. Also remove the cell |
331 // highlight on the button image, added when it was clicked. | 335 // highlight on the button image, added when it was clicked. |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 } | 463 } |
460 | 464 |
461 // Workaround for http://crbug.com/324365: AppKit in Mavericks tries to call | 465 // Workaround for http://crbug.com/324365: AppKit in Mavericks tries to call |
462 // - [NSButtonCell item] when inspecting accessibility. Without this, an | 466 // - [NSButtonCell item] when inspecting accessibility. Without this, an |
463 // unrecognized selector exception is thrown inside AppKit, crashing Chrome. | 467 // unrecognized selector exception is thrown inside AppKit, crashing Chrome. |
464 - (id)item { | 468 - (id)item { |
465 return nil; | 469 return nil; |
466 } | 470 } |
467 | 471 |
468 @end | 472 @end |
OLD | NEW |