Chromium Code Reviews| 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..63bd44bef4db541d31873277e20b8fa04248bde1 |
| --- /dev/null |
| +++ b/chrome/browser/ui/cocoa/profiles/avatar_button.mm |
| @@ -0,0 +1,49 @@ |
| +// 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*)theEvent; |
| +- (void)performRightClick:(id)sender; |
| + |
| +@end |
| + |
| +@implementation AvatarButton |
| + |
| +// 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.
|
| +// See: http://stackoverflow.com/a/5819695 |
|
Robert Sesek
2015/02/17 18:40:46
Remove.
anthonyvd
2015/02/18 00:02:24
Done.
|
| +- (void)rightMouseDown:(NSEvent*)theEvent { |
|
Alexei Svitkine (slow)
2015/02/17 16:43:26
Nit: theEvent -> event
anthonyvd
2015/02/18 00:02:24
Done.
|
| + 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.
|
| + BOOL mouseInBounds = NO; |
| + hoverState_ = kHoverStateMouseDown; |
| + |
| + do { |
| + mouseInBounds = NSPointInRect( |
| + [self convertPoint:[newEvent locationInWindow] fromView:nil], |
| + [self convertRect:[self frame] fromView:nil]); |
| + |
| + newEvent = [[self window] |
| + nextEventMatchingMask:NSRightMouseDraggedMask | |
| + NSRightMouseUpMask]; |
|
Robert Sesek
2015/02/17 18:40:46
nit: align with the 'N'
anthonyvd
2015/02/18 00:02:24
Done.
|
| + } while (NSRightMouseUp != [newEvent type]); |
| + |
| + hoverState_ = kHoverStateNone; |
| + |
| + if (mouseInBounds) { |
| + hoverState_ = kHoverStateMouseOver; |
| + [self performRightClick:nil]; |
| + } |
| +} |
| + |
| +- (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.
|
| + [[super target] performSelector:rightAction withObject:self]; |
| +} |
| + |
| +- (void)setRightAction:(SEL)selector { |
| + rightAction = selector; |
| +} |
| + |
| +@end |