Index: ui/views/cocoa/bridged_content_view.mm |
diff --git a/ui/views/cocoa/bridged_content_view.mm b/ui/views/cocoa/bridged_content_view.mm |
index bd9a511a24468e0b4901e9f184bcb5e6217e8919..de2d12ea7d10a7d0e8335abe0a1326853ada4de6 100644 |
--- a/ui/views/cocoa/bridged_content_view.mm |
+++ b/ui/views/cocoa/bridged_content_view.mm |
@@ -7,6 +7,15 @@ |
#include "base/logging.h" |
#include "ui/gfx/canvas_paint_mac.h" |
#include "ui/views/view.h" |
+#include "ui/views/widget/widget.h" |
+ |
+@interface BridgedContentView () |
+ |
+// Translates the location of |theEvent| to toolkit-views coordinates and passes |
+// the event to NativeWidgetMac for handling. |
+- (void)handleMouseEvent:(NSEvent*)theEvent; |
+ |
+@end |
@implementation BridgedContentView |
@@ -29,8 +38,22 @@ |
hostedView_ = NULL; |
} |
+// BridgedContentView private implementation. |
+ |
+- (void)handleMouseEvent:(NSEvent*)theEvent { |
+ if (!hostedView_) |
+ return; |
+ |
+ ui::MouseEvent event(theEvent); |
+ hostedView_->GetWidget()->OnMouseEvent(&event); |
+} |
+ |
// NSView implementation. |
+- (BOOL)acceptsFirstResponder { |
+ return YES; |
+} |
+ |
- (void)setFrameSize:(NSSize)newSize { |
[super setFrameSize:newSize]; |
if (!hostedView_) |
@@ -47,4 +70,53 @@ |
hostedView_->Paint(&canvas, views::CullSet()); |
} |
+- (void)mouseDown:(NSEvent*)theEvent { |
+ [self handleMouseEvent:theEvent]; |
+} |
+ |
+- (void)rightMouseDown:(NSEvent*)theEvent { |
+ [self handleMouseEvent:theEvent]; |
+} |
+ |
+- (void)otherMouseDown:(NSEvent*)theEvent { |
+ [self handleMouseEvent:theEvent]; |
+} |
+ |
+- (void)mouseUp:(NSEvent*)theEvent { |
+ [self handleMouseEvent:theEvent]; |
+} |
+ |
+- (void)rightMouseUp:(NSEvent*)theEvent { |
+ [self handleMouseEvent:theEvent]; |
+} |
+ |
+- (void)otherMouseUp:(NSEvent*)theEvent { |
+ [self handleMouseEvent:theEvent]; |
+} |
+ |
+- (void)mouseDragged:(NSEvent*)theEvent { |
+ [self handleMouseEvent:theEvent]; |
+} |
+ |
+- (void)rightMouseDragged:(NSEvent*)theEvent { |
+ [self handleMouseEvent:theEvent]; |
+} |
+ |
+- (void)otherMouseDragged:(NSEvent*)theEvent { |
+ [self handleMouseEvent:theEvent]; |
+} |
+ |
+- (void)mouseMoved:(NSEvent*)theEvent { |
+ // Note: mouseEntered: and mouseExited: are not handled separately. |
+ // |hostedView_| is responsible for converting the move events into entered |
+ // and exited events for the view heirarchy. |
+ // TODO(tapted): Install/uninstall tracking areas when required so that the |
+ // NSView will receive these events outside of tests. |
+ [self handleMouseEvent:theEvent]; |
+} |
+ |
+- (void)scrollWheel:(NSEvent*)theEvent { |
+ [self handleMouseEvent:theEvent]; |
+} |
+ |
@end |