OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import "chrome/browser/ui/cocoa/hover_button.h" | 5 #import "chrome/browser/ui/cocoa/hover_button.h" |
6 | 6 |
7 #import "chrome/browser/ui/cocoa/tracking_area.h" | 7 #import "chrome/browser/ui/cocoa/tracking_area.h" |
8 | 8 |
9 @implementation HoverButton | 9 @implementation HoverButton |
10 | 10 |
(...skipping 23 matching lines...) Expand all Loading... |
34 self.hoverState = kHoverStateMouseOver; | 34 self.hoverState = kHoverStateMouseOver; |
35 } | 35 } |
36 | 36 |
37 - (void)mouseExited:(NSEvent*)theEvent { | 37 - (void)mouseExited:(NSEvent*)theEvent { |
38 self.hoverState = kHoverStateNone; | 38 self.hoverState = kHoverStateNone; |
39 } | 39 } |
40 | 40 |
41 - (void)mouseDown:(NSEvent*)theEvent { | 41 - (void)mouseDown:(NSEvent*)theEvent { |
42 self.hoverState = kHoverStateMouseDown; | 42 self.hoverState = kHoverStateMouseDown; |
43 // The hover button needs to hold onto itself here for a bit. Otherwise, | 43 // The hover button needs to hold onto itself here for a bit. Otherwise, |
44 // it can be freed while |super mouseDown:| is in it's loop, and the | 44 // it can be freed while |super mouseDown:| is in its loop, and the |
45 // |checkImageState| call will crash. | 45 // |checkImageState| call will crash. |
46 // http://crbug.com/28220 | 46 // http://crbug.com/28220 |
47 scoped_nsobject<HoverButton> myself([self retain]); | 47 scoped_nsobject<HoverButton> myself([self retain]); |
48 | 48 |
49 [super mouseDown:theEvent]; | 49 [super mouseDown:theEvent]; |
50 // We need to check the image state after the mouseDown event loop finishes. | 50 // We need to check the image state after the mouseDown event loop finishes. |
51 // It's possible that we won't get a mouseExited event if the button was | 51 // It's possible that we won't get a mouseExited event if the button was |
52 // moved under the mouse during tab resize, instead of the mouse moving over | 52 // moved under the mouse during tab resize, instead of the mouse moving over |
53 // the button. | 53 // the button. |
54 // http://crbug.com/31279 | 54 // http://crbug.com/31279 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 self.hoverState = NSPointInRect(mouseLoc, [self bounds]) ? | 98 self.hoverState = NSPointInRect(mouseLoc, [self bounds]) ? |
99 kHoverStateMouseOver : kHoverStateNone; | 99 kHoverStateMouseOver : kHoverStateNone; |
100 } | 100 } |
101 | 101 |
102 - (void)setHoverState:(HoverState)state { | 102 - (void)setHoverState:(HoverState)state { |
103 hoverState_ = state; | 103 hoverState_ = state; |
104 [self setNeedsDisplay:YES]; | 104 [self setNeedsDisplay:YES]; |
105 } | 105 } |
106 | 106 |
107 @end | 107 @end |
OLD | NEW |