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

Side by Side 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, 10 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
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/download_item_button.h" 5 #import "chrome/browser/cocoa/download_item_button.h"
6 6
7 #include "base/logging.h"
7 #include "base/sys_string_conversions.h" 8 #include "base/sys_string_conversions.h"
9 #import "chrome/browser/cocoa/download_item_cell.h"
10 #import "chrome/browser/cocoa/download_item_controller.h"
8 11
9 @implementation DownloadItemButton 12 @implementation DownloadItemButton
10 13
11 @synthesize download = downloadPath_; 14 @synthesize download = downloadPath_;
15 @synthesize controller = controller_;
12 16
13 // Overridden from DraggableButton. 17 // Overridden from DraggableButton.
14 - (void)beginDrag:(NSEvent*)event { 18 - (void)beginDrag:(NSEvent*)event {
15 if (!downloadPath_.empty()) { 19 if (!downloadPath_.empty()) {
16 NSString* filename = base::SysUTF8ToNSString(downloadPath_.value()); 20 NSString* filename = base::SysUTF8ToNSString(downloadPath_.value());
17 [self dragFile:filename fromRect:[self bounds] slideBack:YES event:event]; 21 [self dragFile:filename fromRect:[self bounds] slideBack:YES event:event];
18 } 22 }
19 } 23 }
20 24
25 // Override to show a context menu on mouse down if clicked over the context
26 // menu area.
27 - (void)mouseDown:(NSEvent*)event {
28 DCHECK(controller_);
29 // Override so that we can pop up a context menu on mouse down.
30 NSCell* cell = [self cell];
31 DCHECK([cell respondsToSelector:@selector(isMouseOverButtonPart)]);
32 if ([reinterpret_cast<DownloadItemCell*>(cell) isMouseOverButtonPart]) {
33 [super mouseDown:event];
34 } else {
35 // Hold a reference to our controller in case the download completes and we
36 // represent a file that's auto-removed (e.g. a theme).
37 scoped_nsobject<DownloadItemController> ref([controller_ retain]);
38 [cell setHighlighted:YES];
39 [[self menu] setDelegate:self];
40 [NSMenu popUpContextMenu:[self menu]
41 withEvent:[NSApp currentEvent]
42 forView:self];
43 }
44 }
45
46 - (void)menuDidClose:(NSMenu*)menu {
47 [[self cell] setHighlighted:NO];
48 }
49
21 @end 50 @end
OLDNEW
« 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