diff options
author | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-01 17:44:39 +0000 |
---|---|---|
committer | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-01 17:44:39 +0000 |
commit | 1ada2bfa909b6f4263b808f7797d9ec2da5303f5 (patch) | |
tree | d52c6588fbeb43742ac1e67b8cdc05aa6f9d5b5b /chrome/browser/cocoa/download_item_button.mm | |
parent | f2664c916bb25862badcb64fa19e8f616d5b02c3 (diff) | |
download | chromium_src-1ada2bfa909b6f4263b808f7797d9ec2da5303f5.zip chromium_src-1ada2bfa909b6f4263b808f7797d9ec2da5303f5.tar.gz chromium_src-1ada2bfa909b6f4263b808f7797d9ec2da5303f5.tar.bz2 |
Show download item menu on mouse down instead of mouse up.
BUG=20812
TEST=
* Click right part of download item. Menu should appear on mouse down.
* After menu is closed, mousing over the menu should not show the depressed state.
* Click left part of download item. File should be opened on mouse up.
* http://crbug.com/28215 should not have regressed.
Review URL: http://codereview.chromium.org/380002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37701 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/download_item_button.mm')
-rw-r--r-- | chrome/browser/cocoa/download_item_button.mm | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/chrome/browser/cocoa/download_item_button.mm b/chrome/browser/cocoa/download_item_button.mm index 41a62c8..dd46c53 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 |