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*)theEvent; | |
| 10 - (void)performRightClick:(id)sender; | |
| 11 | |
| 12 @end | |
| 13 | |
| 14 @implementation AvatarButton | |
| 15 | |
| 16 // Override rightMouseDown and implement a custom mouse tracking loop | |
|
Robert Sesek
2015/02/17 18:40:46
nit: punctuation
anthonyvd
2015/02/18 00:02:24
Done.
| |
| 17 // See: http://stackoverflow.com/a/5819695 | |
|
Robert Sesek
2015/02/17 18:40:46
Remove.
anthonyvd
2015/02/18 00:02:24
Done.
| |
| 18 - (void)rightMouseDown:(NSEvent*)theEvent { | |
|
Alexei Svitkine (slow)
2015/02/17 16:43:26
Nit: theEvent -> event
anthonyvd
2015/02/18 00:02:24
Done.
| |
| 19 NSEvent *newEvent = theEvent; | |
|
Alexei Svitkine (slow)
2015/02/17 16:43:26
Nit: * should be left of the space.
Robert Sesek
2015/02/17 18:40:46
naming: nextEvent
anthonyvd
2015/02/18 00:02:24
Done.
anthonyvd
2015/02/18 00:02:24
Done.
| |
| 20 BOOL mouseInBounds = NO; | |
| 21 hoverState_ = kHoverStateMouseDown; | |
| 22 | |
| 23 do { | |
| 24 mouseInBounds = NSPointInRect( | |
| 25 [self convertPoint:[newEvent locationInWindow] fromView:nil], | |
| 26 [self convertRect:[self frame] fromView:nil]); | |
| 27 | |
| 28 newEvent = [[self window] | |
| 29 nextEventMatchingMask:NSRightMouseDraggedMask | | |
| 30 NSRightMouseUpMask]; | |
|
Robert Sesek
2015/02/17 18:40:46
nit: align with the 'N'
anthonyvd
2015/02/18 00:02:24
Done.
| |
| 31 } while (NSRightMouseUp != [newEvent type]); | |
| 32 | |
| 33 hoverState_ = kHoverStateNone; | |
| 34 | |
| 35 if (mouseInBounds) { | |
| 36 hoverState_ = kHoverStateMouseOver; | |
| 37 [self performRightClick:nil]; | |
| 38 } | |
| 39 } | |
| 40 | |
| 41 - (void)performRightClick:(id)sender { | |
|
Alexei Svitkine (slow)
2015/02/17 16:43:26
Why have a sender param if you're passing in nil o
anthonyvd
2015/02/18 00:02:24
Done.
| |
| 42 [[super target] performSelector:rightAction withObject:self]; | |
| 43 } | |
| 44 | |
| 45 - (void)setRightAction:(SEL)selector { | |
| 46 rightAction = selector; | |
| 47 } | |
| 48 | |
| 49 @end | |
| OLD | NEW |