| 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..6099d948e2225a670da4aa3912ae771c1a1f0693
|
| --- /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.
|
| +- (void)rightMouseDown:(NSEvent*)event {
|
| + NSEvent* nextEvent = event;
|
| + BOOL mouseInBounds = NO;
|
| + hoverState_ = kHoverStateMouseDown;
|
| +
|
| + do {
|
| + mouseInBounds = NSPointInRect(
|
| + [self convertPoint:[nextEvent locationInWindow] fromView:nil],
|
| + [self convertRect:[self frame] fromView:nil]);
|
| +
|
| + nextEvent = [[self window]
|
| + nextEventMatchingMask:NSRightMouseDraggedMask |
|
| + NSRightMouseUpMask];
|
| + } 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
|
|
|