Chromium Code Reviews| 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. | |
|
Alexei Svitkine (slow)
2015/02/19 16:40:44
Nit: Change verb tense - "Overrides" and "implemen
anthonyvd
2015/02/20 18:50:47
Done.
| |
| 17 - (void)rightMouseDown:(NSEvent*)event { | |
| 18 NSEvent* nextEvent = event; | |
| 19 BOOL mouseInBounds = NO; | |
| 20 hoverState_ = kHoverStateMouseDown; | |
| 21 | |
| 22 do { | |
| 23 nextEvent = [[self window] | |
| 24 nextEventMatchingMask:NSRightMouseDraggedMask | | |
| 25 NSRightMouseUpMask]; | |
| 26 | |
| 27 mouseInBounds = NSPointInRect( | |
| 28 [self convertPoint:[nextEvent locationInWindow] fromView:nil], | |
| 29 [self convertRect:[self frame] fromView:nil]); | |
| 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 |