| 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 #include "ui/base/cocoa/base_view.h" | 5 #include "ui/base/cocoa/base_view.h" |
| 6 | 6 |
| 7 #include "base/mac/mac_util.h" | 7 #include "base/mac/mac_util.h" |
| 8 | 8 |
| 9 NSString* kViewDidBecomeFirstResponder = | 9 NSString* kViewDidBecomeFirstResponder = |
| 10 @"Chromium.kViewDidBecomeFirstResponder"; | 10 @"Chromium.kViewDidBecomeFirstResponder"; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 // Derived classes should return kEventHandled if they handled an event, | 76 // Derived classes should return kEventHandled if they handled an event, |
| 77 // otherwise it will be forwarded on to |super|. | 77 // otherwise it will be forwarded on to |super|. |
| 78 return kEventNotHandled; | 78 return kEventNotHandled; |
| 79 } | 79 } |
| 80 | 80 |
| 81 - (void)forceTouchEvent:(NSEvent*)theEvent { | 81 - (void)forceTouchEvent:(NSEvent*)theEvent { |
| 82 // This method left intentionally blank. | 82 // This method left intentionally blank. |
| 83 } | 83 } |
| 84 | 84 |
| 85 - (void)mouseDown:(NSEvent*)theEvent { | 85 - (void)mouseDown:(NSEvent*)theEvent { |
| 86 dragging_ = YES; | |
| 87 [self mouseEvent:theEvent]; | 86 [self mouseEvent:theEvent]; |
| 88 } | 87 } |
| 89 | 88 |
| 90 - (void)rightMouseDown:(NSEvent*)theEvent { | 89 - (void)rightMouseDown:(NSEvent*)theEvent { |
| 91 [self mouseEvent:theEvent]; | 90 [self mouseEvent:theEvent]; |
| 92 } | 91 } |
| 93 | 92 |
| 94 - (void)otherMouseDown:(NSEvent*)theEvent { | 93 - (void)otherMouseDown:(NSEvent*)theEvent { |
| 95 [self mouseEvent:theEvent]; | 94 [self mouseEvent:theEvent]; |
| 96 } | 95 } |
| 97 | 96 |
| 98 - (void)mouseUp:(NSEvent*)theEvent { | 97 - (void)mouseUp:(NSEvent*)theEvent { |
| 99 [self mouseEvent:theEvent]; | 98 [self mouseEvent:theEvent]; |
| 100 | |
| 101 dragging_ = NO; | |
| 102 if (pendingExitEvent_.get()) { | |
| 103 NSEvent* exitEvent = | |
| 104 [NSEvent enterExitEventWithType:NSMouseExited | |
| 105 location:[theEvent locationInWindow] | |
| 106 modifierFlags:[theEvent modifierFlags] | |
| 107 timestamp:[theEvent timestamp] | |
| 108 windowNumber:[theEvent windowNumber] | |
| 109 context:[theEvent context] | |
| 110 eventNumber:[pendingExitEvent_.get() eventNumber] | |
| 111 trackingNumber:[pendingExitEvent_.get() trackingNumber] | |
| 112 userData:[pendingExitEvent_.get() userData]]; | |
| 113 [self mouseEvent:exitEvent]; | |
| 114 pendingExitEvent_.reset(); | |
| 115 } | |
| 116 } | 99 } |
| 117 | 100 |
| 118 - (void)rightMouseUp:(NSEvent*)theEvent { | 101 - (void)rightMouseUp:(NSEvent*)theEvent { |
| 119 [self mouseEvent:theEvent]; | 102 [self mouseEvent:theEvent]; |
| 120 } | 103 } |
| 121 | 104 |
| 122 - (void)otherMouseUp:(NSEvent*)theEvent { | 105 - (void)otherMouseUp:(NSEvent*)theEvent { |
| 123 [self mouseEvent:theEvent]; | 106 [self mouseEvent:theEvent]; |
| 124 } | 107 } |
| 125 | 108 |
| 126 - (void)mouseMoved:(NSEvent*)theEvent { | 109 - (void)mouseMoved:(NSEvent*)theEvent { |
| 127 [self mouseEvent:theEvent]; | 110 [self mouseEvent:theEvent]; |
| 128 } | 111 } |
| 129 | 112 |
| 130 - (void)mouseDragged:(NSEvent*)theEvent { | 113 - (void)mouseDragged:(NSEvent*)theEvent { |
| 131 [self mouseEvent:theEvent]; | 114 [self mouseEvent:theEvent]; |
| 132 } | 115 } |
| 133 | 116 |
| 134 - (void)rightMouseDragged:(NSEvent*)theEvent { | 117 - (void)rightMouseDragged:(NSEvent*)theEvent { |
| 135 [self mouseEvent:theEvent]; | 118 [self mouseEvent:theEvent]; |
| 136 } | 119 } |
| 137 | 120 |
| 138 - (void)otherMouseDragged:(NSEvent*)theEvent { | 121 - (void)otherMouseDragged:(NSEvent*)theEvent { |
| 139 [self mouseEvent:theEvent]; | 122 [self mouseEvent:theEvent]; |
| 140 } | 123 } |
| 141 | 124 |
| 142 - (void)mouseEntered:(NSEvent*)theEvent { | 125 - (void)mouseEntered:(NSEvent*)theEvent { |
| 143 if (pendingExitEvent_.get()) { | |
| 144 pendingExitEvent_.reset(); | |
| 145 return; | |
| 146 } | |
| 147 | |
| 148 [self mouseEvent:theEvent]; | 126 [self mouseEvent:theEvent]; |
| 149 } | 127 } |
| 150 | 128 |
| 151 - (void)mouseExited:(NSEvent*)theEvent { | 129 - (void)mouseExited:(NSEvent*)theEvent { |
| 152 // The tracking area will send an exit event even during a drag, which isn't | |
| 153 // how the event flow for drags should work. This stores the exit event, and | |
| 154 // sends it when the drag completes instead. | |
| 155 if (dragging_) { | |
| 156 pendingExitEvent_.reset([theEvent retain]); | |
| 157 return; | |
| 158 } | |
| 159 | |
| 160 [self mouseEvent:theEvent]; | 130 [self mouseEvent:theEvent]; |
| 161 } | 131 } |
| 162 | 132 |
| 163 - (void)keyDown:(NSEvent*)theEvent { | 133 - (void)keyDown:(NSEvent*)theEvent { |
| 164 if ([self keyEvent:theEvent] != kEventHandled) | 134 if ([self keyEvent:theEvent] != kEventHandled) |
| 165 [super keyDown:theEvent]; | 135 [super keyDown:theEvent]; |
| 166 } | 136 } |
| 167 | 137 |
| 168 - (void)keyUp:(NSEvent*)theEvent { | 138 - (void)keyUp:(NSEvent*)theEvent { |
| 169 if ([self keyEvent:theEvent] != kEventHandled) | 139 if ([self keyEvent:theEvent] != kEventHandled) |
| (...skipping 24 matching lines...) Expand all Loading... |
| 194 return new_rect; | 164 return new_rect; |
| 195 } | 165 } |
| 196 | 166 |
| 197 - (NSRect)flipRectToNSRect:(gfx::Rect)rect { | 167 - (NSRect)flipRectToNSRect:(gfx::Rect)rect { |
| 198 NSRect new_rect(NSRectFromCGRect(rect.ToCGRect())); | 168 NSRect new_rect(NSRectFromCGRect(rect.ToCGRect())); |
| 199 new_rect.origin.y = NSHeight([self bounds]) - NSMaxY(new_rect); | 169 new_rect.origin.y = NSHeight([self bounds]) - NSMaxY(new_rect); |
| 200 return new_rect; | 170 return new_rect; |
| 201 } | 171 } |
| 202 | 172 |
| 203 @end | 173 @end |
| OLD | NEW |