Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(692)

Side by Side Diff: chrome/browser/ui/cocoa/profiles/avatar_button.mm

Issue 916523003: Bring up fast user switcher on right-click of the avatar menu on Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698