OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #import "chrome/browser/ui/cocoa/profiles/avatar_button.h" |
| 6 |
| 7 @interface AvatarButton (Private) |
| 8 |
| 9 - (void)rightMouseDown:(NSEvent*)event; |
| 10 - (void)performRightClick; |
| 11 |
| 12 @end |
| 13 |
| 14 @implementation AvatarButton |
| 15 |
| 16 // Override rightMouseDown and implement a custom mouse tracking loop. |
| 17 - (void)rightMouseDown:(NSEvent*)event { |
| 18 NSEvent* nextEvent = event; |
| 19 BOOL mouseInBounds = NO; |
| 20 hoverState_ = kHoverStateMouseDown; |
| 21 |
| 22 do { |
| 23 mouseInBounds = NSPointInRect( |
| 24 [self convertPoint:[nextEvent locationInWindow] fromView:nil], |
| 25 [self convertRect:[self frame] fromView:nil]); |
| 26 |
| 27 nextEvent = [[self window] |
| 28 nextEventMatchingMask:NSRightMouseDraggedMask | |
| 29 NSRightMouseUpMask]; |
| 30 } while (NSRightMouseUp != [nextEvent type]); |
| 31 |
| 32 hoverState_ = kHoverStateNone; |
| 33 |
| 34 if (mouseInBounds) { |
| 35 hoverState_ = kHoverStateMouseOver; |
| 36 [self performRightClick]; |
| 37 } |
| 38 } |
| 39 |
| 40 - (void)performRightClick { |
| 41 [[super target] performSelector:rightAction withObject:self]; |
| 42 } |
| 43 |
| 44 - (void)setRightAction:(SEL)selector { |
| 45 rightAction = selector; |
| 46 } |
| 47 |
| 48 @end |
OLD | NEW |