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

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

Issue 437055: Mac: fix Esc-key cancellation of bookmark bar button drags. (Closed)
Patch Set: Updated/eliminated some comments. Created 11 years, 1 month 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/bookmark_button.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/bookmark_button.mm
diff --git a/chrome/browser/cocoa/bookmark_button.mm b/chrome/browser/cocoa/bookmark_button.mm
index 40a1e0a304944bb6f67d53ac47dc431af1646d7c..1fdf4a3ace88490571f0888fbef3690ea5176bc0 100644
--- a/chrome/browser/cocoa/bookmark_button.mm
+++ b/chrome/browser/cocoa/bookmark_button.mm
@@ -46,6 +46,9 @@ const CGFloat kDragImageOpacity = 0.8;
}
- (void)beginDrag:(NSEvent*)event {
+ // Starting drag. Never start another drag until another mouse down.
+ mayDragStart_ = NO;
+
NSSize dragOffset = NSMakeSize(0.0, 0.0);
NSPasteboard* pboard = [NSPasteboard pasteboardWithName:NSDragPboard];
[pboard declareTypes:[NSArray arrayWithObject:kBookmarkButtonDragType]
@@ -82,11 +85,16 @@ const CGFloat kDragImageOpacity = 0.8;
}
- (void)mouseUp:(NSEvent*)theEvent {
+ // Make sure that we can't start a drag until we see a mouse down again.
+ mayDragStart_ = NO;
+
// This conditional is never true (DnD loops in Cocoa eat the mouse
// up) but I added it in case future versions of Cocoa do unexpected
// things.
- if (beingDragged_)
+ if (beingDragged_) {
+ NOTREACHED();
return [super mouseUp:theEvent];
+ }
// There are non-drag cases where a mouseUp: may happen
// (e.g. mouse-down, cmd-tab to another application, move mouse,
@@ -103,6 +111,7 @@ const CGFloat kDragImageOpacity = 0.8;
// Mimic "begin a click" operation visually. Do NOT follow through
// with normal button event handling.
- (void)mouseDown:(NSEvent*)theEvent {
+ mayDragStart_ = YES;
[[self cell] setHighlighted:YES];
initialMouseDownLocation_ = [theEvent locationInWindow];
}
@@ -122,12 +131,11 @@ const CGFloat kDragImageOpacity = 0.8;
}
- (void)mouseDragged:(NSEvent*)theEvent {
- if (beingDragged_)
+ if (beingDragged_) {
[super mouseDragged:theEvent];
- else {
- if (draggable_ && [self hasCrossedDragThreshold:theEvent]) {
- [self beginDrag:theEvent];
- }
+ } else if (draggable_ && mayDragStart_ &&
+ [self hasCrossedDragThreshold:theEvent]) {
+ [self beginDrag:theEvent];
}
}
« no previous file with comments | « chrome/browser/cocoa/bookmark_button.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698