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

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: Cleanup 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*)event;
10 - (void)performRightClick;
11
12 @end
13
14 @implementation AvatarButton
15
16 // Overrides -rightMouseDown and implements 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 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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698