OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/cocoa/bookmarks/bookmark_button.h" | 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #import "base/memory/scoped_nsobject.h" | 8 #import "base/memory/scoped_nsobject.h" |
9 #include "chrome/browser/bookmarks/bookmark_model.h" | 9 #include "chrome/browser/bookmarks/bookmark_model.h" |
10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.h" | 10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.h" |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 | 345 |
346 - (void)mouseDragged:(NSEvent*)theEvent { | 346 - (void)mouseDragged:(NSEvent*)theEvent { |
347 if ([delegate_ respondsToSelector:@selector(mouseDragged:)]) | 347 if ([delegate_ respondsToSelector:@selector(mouseDragged:)]) |
348 [id(delegate_) mouseDragged:theEvent]; | 348 [id(delegate_) mouseDragged:theEvent]; |
349 } | 349 } |
350 | 350 |
351 + (BookmarkButton*)draggedButton { | 351 + (BookmarkButton*)draggedButton { |
352 return gDraggedButton; | 352 return gDraggedButton; |
353 } | 353 } |
354 | 354 |
| 355 - (BOOL)canBecomeKeyView { |
| 356 // If button is an item in a folder menu, don't become key. |
| 357 return ![[self cell] isFolderButtonCell]; |
| 358 } |
| 359 |
355 // This only gets called after a click that wasn't a drag, and only on folders. | 360 // This only gets called after a click that wasn't a drag, and only on folders. |
356 - (void)secondaryMouseUpAction:(BOOL)wasInside { | 361 - (void)secondaryMouseUpAction:(BOOL)wasInside { |
357 const NSTimeInterval kShortClickLength = 0.5; | 362 const NSTimeInterval kShortClickLength = 0.5; |
358 // Long clicks that end over the folder button result in the menu hiding. | 363 // Long clicks that end over the folder button result in the menu hiding. |
359 if (wasInside && ([self durationMouseWasDown] > kShortClickLength)) { | 364 if (wasInside && ([self durationMouseWasDown] > kShortClickLength)) { |
360 [[self target] performSelector:[self action] withObject:self]; | 365 [[self target] performSelector:[self action] withObject:self]; |
361 } else { | 366 } else { |
362 // Mouse tracked out of button during menu track. Hide menus. | 367 // Mouse tracked out of button during menu track. Hide menus. |
363 if (!wasInside) | 368 if (!wasInside) |
364 [delegate_ bookmarkDragDidEnd:self | 369 [delegate_ bookmarkDragDidEnd:self |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 [image drawAtPoint:NSMakePoint(0, 0) | 422 [image drawAtPoint:NSMakePoint(0, 0) |
418 fromRect:NSMakeRect(0, 0, NSWidth(bounds), NSHeight(bounds)) | 423 fromRect:NSMakeRect(0, 0, NSWidth(bounds), NSHeight(bounds)) |
419 operation:NSCompositeSourceOver | 424 operation:NSCompositeSourceOver |
420 fraction:kDragImageOpacity]; | 425 fraction:kDragImageOpacity]; |
421 | 426 |
422 [dragImage unlockFocus]; | 427 [dragImage unlockFocus]; |
423 return dragImage; | 428 return dragImage; |
424 } | 429 } |
425 | 430 |
426 @end // @implementation BookmarkButton(Private) | 431 @end // @implementation BookmarkButton(Private) |
OLD | NEW |