Chromium Code Reviews| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 // This method left intentionally blank. | 71 // This method left intentionally blank. |
| 72 } | 72 } |
| 73 | 73 |
| 74 - (EventHandled)keyEvent:(NSEvent*)theEvent { | 74 - (EventHandled)keyEvent:(NSEvent*)theEvent { |
| 75 // The default implementation of this method does not handle any key events. | 75 // The default implementation of this method does not handle any key events. |
| 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 { | |
| 82 // This method left intentionally blank. | |
| 83 } | |
| 84 | |
| 81 - (void)mouseDown:(NSEvent*)theEvent { | 85 - (void)mouseDown:(NSEvent*)theEvent { |
| 82 dragging_ = YES; | 86 dragging_ = YES; |
| 83 [self mouseEvent:theEvent]; | 87 [self mouseEvent:theEvent]; |
| 84 } | 88 } |
| 85 | 89 |
| 86 - (void)rightMouseDown:(NSEvent*)theEvent { | 90 - (void)rightMouseDown:(NSEvent*)theEvent { |
| 87 [self mouseEvent:theEvent]; | 91 [self mouseEvent:theEvent]; |
| 88 } | 92 } |
| 89 | 93 |
| 90 - (void)otherMouseDown:(NSEvent*)theEvent { | 94 - (void)otherMouseDown:(NSEvent*)theEvent { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 159 - (void)keyDown:(NSEvent*)theEvent { | 163 - (void)keyDown:(NSEvent*)theEvent { |
| 160 if ([self keyEvent:theEvent] != kEventHandled) | 164 if ([self keyEvent:theEvent] != kEventHandled) |
| 161 [super keyDown:theEvent]; | 165 [super keyDown:theEvent]; |
| 162 } | 166 } |
| 163 | 167 |
| 164 - (void)keyUp:(NSEvent*)theEvent { | 168 - (void)keyUp:(NSEvent*)theEvent { |
| 165 if ([self keyEvent:theEvent] != kEventHandled) | 169 if ([self keyEvent:theEvent] != kEventHandled) |
| 166 [super keyUp:theEvent]; | 170 [super keyUp:theEvent]; |
| 167 } | 171 } |
| 168 | 172 |
| 173 - (void)pressureChangeWithEvent:(NSEvent*)theEvent { | |
| 174 NSInteger newStage = [theEvent stage]; | |
| 175 if (pressureEventStage_ == newStage) | |
| 176 return; | |
| 177 | |
| 178 // Call the force touch event when the stages reaches | |
| 179 // 2, which is the value for force touch | |
|
Robert Sesek
2015/12/21 22:30:21
nit: punctuation.
spqchan
2016/01/06 22:52:31
Done.
| |
| 180 if (newStage == 2) { | |
| 181 [self forceTouchEvent:theEvent]; | |
| 182 } | |
| 183 pressureEventStage_ = newStage; | |
| 184 } | |
| 185 | |
| 169 - (void)flagsChanged:(NSEvent*)theEvent { | 186 - (void)flagsChanged:(NSEvent*)theEvent { |
| 170 if ([self keyEvent:theEvent] != kEventHandled) | 187 if ([self keyEvent:theEvent] != kEventHandled) |
| 171 [super flagsChanged:theEvent]; | 188 [super flagsChanged:theEvent]; |
| 172 } | 189 } |
| 173 | 190 |
| 174 - (gfx::Rect)flipNSRectToRect:(NSRect)rect { | 191 - (gfx::Rect)flipNSRectToRect:(NSRect)rect { |
| 175 gfx::Rect new_rect(NSRectToCGRect(rect)); | 192 gfx::Rect new_rect(NSRectToCGRect(rect)); |
| 176 new_rect.set_y(NSHeight([self bounds]) - new_rect.bottom()); | 193 new_rect.set_y(NSHeight([self bounds]) - new_rect.bottom()); |
| 177 return new_rect; | 194 return new_rect; |
| 178 } | 195 } |
| 179 | 196 |
| 180 - (NSRect)flipRectToNSRect:(gfx::Rect)rect { | 197 - (NSRect)flipRectToNSRect:(gfx::Rect)rect { |
| 181 NSRect new_rect(NSRectFromCGRect(rect.ToCGRect())); | 198 NSRect new_rect(NSRectFromCGRect(rect.ToCGRect())); |
| 182 new_rect.origin.y = NSHeight([self bounds]) - NSMaxY(new_rect); | 199 new_rect.origin.y = NSHeight([self bounds]) - NSMaxY(new_rect); |
| 183 return new_rect; | 200 return new_rect; |
| 184 } | 201 } |
| 185 | 202 |
| 186 @end | 203 @end |
| OLD | NEW |