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

Side by Side Diff: chrome/browser/ui/cocoa/toolbar/toolbar_button.mm

Issue 657443004: MacViews: Get views based toolbar to compile on the Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@views-findbar
Patch Set: Rebase Created 6 years, 2 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 (c) 2011 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/toolbar/toolbar_button.h"
6
7 @implementation ToolbarButton
8
9 @synthesize handleMiddleClick = handleMiddleClick_;
10
11 - (void)otherMouseDown:(NSEvent*)theEvent {
12 if (![self shouldHandleEvent:theEvent]) {
13 [super otherMouseDown:theEvent];
14 return;
15 }
16
17 NSEvent* nextEvent = theEvent;
18 BOOL isInside;
19
20 // Loop until middle button is released. Also, the mouse cursor is outside of
21 // the button, the button should not be highlighted.
22 do {
23 NSPoint mouseLoc = [self convertPoint:[nextEvent locationInWindow]
24 fromView:nil];
25 isInside = [self mouse:mouseLoc inRect:[self bounds]];
26 [self highlight:isInside];
27 [self setState:isInside ? NSOnState : NSOffState];
28
29 NSUInteger mask = NSOtherMouseDraggedMask | NSOtherMouseUpMask;
30 nextEvent = [[self window] nextEventMatchingMask:mask];
31 } while (!([nextEvent buttonNumber] == 2 &&
32 [nextEvent type] == NSOtherMouseUp));
33
34 // Discard the events before the middle button up event.
35 // If we don't discard it, the events will be re-processed later.
36 [[self window] discardEventsMatchingMask:NSAnyEventMask
37 beforeEvent:nextEvent];
38
39 [self highlight:NO];
40 [self setState:NSOffState];
41 if (isInside)
42 [self sendAction:[self action] to:[self target]];
43 }
44
45 - (BOOL)shouldHandleEvent:(NSEvent*)theEvent {
46 // |buttonNumber| is the mouse button whose action triggered theEvent.
47 // 2 corresponds to the middle mouse button.
48 return handleMiddleClick_ && [theEvent buttonNumber] == 2;
49 }
50
51 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/toolbar/toolbar_button.h ('k') | chrome/browser/ui/cocoa/toolbar/toolbar_button_cocoa.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698