1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #import "chrome/browser/ui/cocoa/profiles/avatar_button.h"
7 @interface AvatarButton (Private)
9 - (void)rightMouseDown:(NSEvent*)event;
10 - (void)performRightClick;
14 @implementation AvatarButton
16 // Overrides -rightMouseDown and implements a custom mouse tracking loop.
17 - (void)rightMouseDown:(NSEvent*)event {
18 NSEvent* nextEvent = event;
19 BOOL mouseInBounds = NO;
20 hoverState_ = kHoverStateMouseDown;
23 nextEvent = [[self window]
24 nextEventMatchingMask:NSRightMouseDraggedMask |
27 mouseInBounds = NSPointInRect(
28 [self convertPoint:[nextEvent locationInWindow] fromView:nil],
29 [self convertRect:[self frame] fromView:nil]);
30 } while (NSRightMouseUp != [nextEvent type]);
32 hoverState_ = kHoverStateNone;
35 hoverState_ = kHoverStateMouseOver;
36 [self performRightClick];
40 - (void)performRightClick {
41 [[super target] performSelector:rightAction_ withObject:self];
44 - (void)setRightAction:(SEL)selector {
45 rightAction_ = selector;