diff options
author | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-25 15:41:05 +0000 |
---|---|---|
committer | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-25 15:41:05 +0000 |
commit | a2d806f5df8b4189ef76014c69e277bed9f849b3 (patch) | |
tree | 156d30592b3e2dffe2226dcd4e9be0204687e738 /chrome/browser/cocoa/bookmark_button.mm | |
parent | 2b07b84191a266cb8c9dd86b6957df4947b136e0 (diff) | |
download | chromium_src-a2d806f5df8b4189ef76014c69e277bed9f849b3.zip chromium_src-a2d806f5df8b4189ef76014c69e277bed9f849b3.tar.gz chromium_src-a2d806f5df8b4189ef76014c69e277bed9f849b3.tar.bz2 |
Mac: fix Esc-key cancellation of bookmark bar button drags.
The drag would be cancelled after pressing Esc, but moving the mouse again would
cause the bookmark bar button to see a drag again and start a new drag. This
patch makes the button wait for the next mouse down.
BUG=28502
TEST=Drag bookmark bar button and keep mouse button; press Esc (and see cancellation animation); move mouse again and make sure a new drag doesn't start.
Review URL: http://codereview.chromium.org/437055
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33067 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/bookmark_button.mm')
-rw-r--r-- | chrome/browser/cocoa/bookmark_button.mm | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/chrome/browser/cocoa/bookmark_button.mm b/chrome/browser/cocoa/bookmark_button.mm index 40a1e0a..1fdf4a3 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]; } } |