OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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/draggable_button.h" | 5 #import "chrome/browser/ui/cocoa/draggable_button.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 | 8 |
9 @implementation DraggableButton | 9 @implementation DraggableButton |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... | |
29 } | 29 } |
30 | 30 |
31 - (void)mouseUp:(NSEvent*)theEvent { | 31 - (void)mouseUp:(NSEvent*)theEvent { |
32 if ([draggableButtonImpl_ mouseUpImpl:theEvent] == | 32 if ([draggableButtonImpl_ mouseUpImpl:theEvent] == |
33 kDraggableButtonMixinCallSuper) { | 33 kDraggableButtonMixinCallSuper) { |
34 [super mouseUp:theEvent]; | 34 [super mouseUp:theEvent]; |
35 } | 35 } |
36 } | 36 } |
37 | 37 |
38 - (void)mouseDown:(NSEvent*)theEvent { | 38 - (void)mouseDown:(NSEvent*)theEvent { |
39 // The impl spins an event loop to distinguish clicks from drags, | |
40 // which could result in our destruction. Wire ourselves down for | |
41 // the duration. | |
42 scoped_nsobject<DraggableButton> keepAlive([self retain]); | |
Robert Sesek
2011/08/23 22:56:48
Would it be better to do this in the impl?
Scott Hess - ex-Googler
2011/08/23 23:04:37
How?
Robert Sesek
2011/08/23 23:10:13
Retain button_ in the Impl in the loop?
| |
43 | |
39 if ([draggableButtonImpl_ mouseDownImpl:theEvent] == | 44 if ([draggableButtonImpl_ mouseDownImpl:theEvent] == |
40 kDraggableButtonMixinCallSuper) { | 45 kDraggableButtonMixinCallSuper) { |
41 [super mouseDown:theEvent]; | 46 [super mouseDown:theEvent]; |
42 } | 47 } |
43 } | 48 } |
44 | 49 |
45 - (void)beginDrag:(NSEvent*)dragEvent { | 50 - (void)beginDrag:(NSEvent*)dragEvent { |
46 // Must be overridden by subclasses. | 51 // Must be overridden by subclasses. |
47 NOTREACHED(); | 52 NOTREACHED(); |
48 } | 53 } |
49 | 54 |
50 @end // @interface DraggableButton | 55 @end // @interface DraggableButton |
OLD | NEW |