Chromium Code Reviews| Index: chrome/browser/ui/cocoa/profiles/avatar_button.mm |
| diff --git a/chrome/browser/ui/cocoa/profiles/avatar_button.mm b/chrome/browser/ui/cocoa/profiles/avatar_button.mm |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0c137127d9a66aa87be8401aac4c499be0a9956c |
| --- /dev/null |
| +++ b/chrome/browser/ui/cocoa/profiles/avatar_button.mm |
| @@ -0,0 +1,48 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#import "chrome/browser/ui/cocoa/profiles/avatar_button.h" |
| + |
| +@interface AvatarButton (Private) |
| + |
| +- (void)rightMouseDown:(NSEvent*)event; |
| +- (void)performRightClick; |
| + |
| +@end |
| + |
| +@implementation AvatarButton |
| + |
| +// Override rightMouseDown and implement a custom mouse tracking loop. |
|
Alexei Svitkine (slow)
2015/02/19 16:40:44
Nit: Change verb tense - "Overrides" and "implemen
anthonyvd
2015/02/20 18:50:47
Done.
|
| +- (void)rightMouseDown:(NSEvent*)event { |
| + NSEvent* nextEvent = event; |
| + BOOL mouseInBounds = NO; |
| + hoverState_ = kHoverStateMouseDown; |
| + |
| + do { |
| + nextEvent = [[self window] |
| + nextEventMatchingMask:NSRightMouseDraggedMask | |
| + NSRightMouseUpMask]; |
| + |
| + mouseInBounds = NSPointInRect( |
| + [self convertPoint:[nextEvent locationInWindow] fromView:nil], |
| + [self convertRect:[self frame] fromView:nil]); |
| + } while (NSRightMouseUp != [nextEvent type]); |
| + |
| + hoverState_ = kHoverStateNone; |
| + |
| + if (mouseInBounds) { |
| + hoverState_ = kHoverStateMouseOver; |
| + [self performRightClick]; |
| + } |
| +} |
| + |
| +- (void)performRightClick { |
| + [[super target] performSelector:rightAction_ withObject:self]; |
| +} |
| + |
| +- (void)setRightAction:(SEL)selector { |
| + rightAction_ = selector; |
| +} |
| + |
| +@end |