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

Unified Diff: chrome/browser/cocoa/download_item_button.mm

Issue 380002: Mac: Show download item menu on mouse down instead of mouse up. (Closed)
Patch Set: comments Created 10 years, 11 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
« no previous file with comments | « chrome/browser/cocoa/download_item_button.h ('k') | chrome/browser/cocoa/download_item_cell.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/download_item_button.mm
diff --git a/chrome/browser/cocoa/download_item_button.mm b/chrome/browser/cocoa/download_item_button.mm
index 41a62c8de35916a2265492cf94da17e680a480e8..dd46c53997ec2b481c799b206daea5f08ccf2fe2 100644
--- a/chrome/browser/cocoa/download_item_button.mm
+++ b/chrome/browser/cocoa/download_item_button.mm
@@ -4,11 +4,15 @@
#import "chrome/browser/cocoa/download_item_button.h"
+#include "base/logging.h"
#include "base/sys_string_conversions.h"
+#import "chrome/browser/cocoa/download_item_cell.h"
+#import "chrome/browser/cocoa/download_item_controller.h"
@implementation DownloadItemButton
@synthesize download = downloadPath_;
+@synthesize controller = controller_;
// Overridden from DraggableButton.
- (void)beginDrag:(NSEvent*)event {
@@ -18,4 +22,29 @@
}
}
+// Override to show a context menu on mouse down if clicked over the context
+// menu area.
+- (void)mouseDown:(NSEvent*)event {
+ DCHECK(controller_);
+ // Override so that we can pop up a context menu on mouse down.
+ NSCell* cell = [self cell];
+ DCHECK([cell respondsToSelector:@selector(isMouseOverButtonPart)]);
+ if ([reinterpret_cast<DownloadItemCell*>(cell) isMouseOverButtonPart]) {
+ [super mouseDown:event];
+ } else {
+ // Hold a reference to our controller in case the download completes and we
+ // represent a file that's auto-removed (e.g. a theme).
+ scoped_nsobject<DownloadItemController> ref([controller_ retain]);
+ [cell setHighlighted:YES];
+ [[self menu] setDelegate:self];
+ [NSMenu popUpContextMenu:[self menu]
+ withEvent:[NSApp currentEvent]
+ forView:self];
+ }
+}
+
+- (void)menuDidClose:(NSMenu*)menu {
+ [[self cell] setHighlighted:NO];
+}
+
@end
« no previous file with comments | « chrome/browser/cocoa/download_item_button.h ('k') | chrome/browser/cocoa/download_item_cell.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698