From fe802fc2edc8e3e78f812254582af0ee91da2ea0 Mon Sep 17 00:00:00 2001 From: David Elliott Date: Mon, 14 Apr 2003 03:51:59 +0000 Subject: [PATCH] Catch and forward the following mouse related events: mouseMoved, mouseEntered, mouseExited mouseDown, mouseDragged, mouseUp rightMouseDown, rightMouseDragged, rightMouseUp otherMouseDown, otherMouseDragged, oterMouseUp git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@20215 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/cocoa/NSView.h | 12 +++++ src/cocoa/NSView.mm | 96 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+) diff --git a/include/wx/cocoa/NSView.h b/include/wx/cocoa/NSView.h index 3fc6c7904f..db6eb26c38 100644 --- a/include/wx/cocoa/NSView.h +++ b/include/wx/cocoa/NSView.h @@ -30,6 +30,18 @@ protected: public: virtual void Cocoa_FrameChanged(void) = 0; virtual bool Cocoa_drawRect(const NSRect &rect) = 0; + virtual bool Cocoa_mouseDown(WX_NSEvent theEvent) = 0; + virtual bool Cocoa_mouseDragged(WX_NSEvent theEvent) = 0; + virtual bool Cocoa_mouseUp(WX_NSEvent theEvent) = 0; + virtual bool Cocoa_mouseMoved(WX_NSEvent theEvent) = 0; + virtual bool Cocoa_mouseEntered(WX_NSEvent theEvent) = 0; + virtual bool Cocoa_mouseExited(WX_NSEvent theEvent) = 0; + virtual bool Cocoa_rightMouseDown(WX_NSEvent theEvent) = 0; + virtual bool Cocoa_rightMouseDragged(WX_NSEvent theEvent) = 0; + virtual bool Cocoa_rightMouseUp(WX_NSEvent theEvent) = 0; + virtual bool Cocoa_otherMouseDown(WX_NSEvent theEvent) = 0; + virtual bool Cocoa_otherMouseDragged(WX_NSEvent theEvent) = 0; + virtual bool Cocoa_otherMouseUp(WX_NSEvent theEvent) = 0; }; #endif // _WX_COCOA_NSVIEW_H_ diff --git a/src/cocoa/NSView.mm b/src/cocoa/NSView.mm index ea69656316..ec0be69062 100644 --- a/src/cocoa/NSView.mm +++ b/src/cocoa/NSView.mm @@ -54,6 +54,18 @@ void wxCocoaNSView::DisassociateNSView(WX_NSView cocoaNSView) } - (void)drawRect: (NSRect)rect; +- (void)mouseDown:(NSEvent *)theEvent; +- (void)mouseDragged:(NSEvent *)theEvent; +- (void)mouseUp:(NSEvent *)theEvent; +- (void)mouseMoved:(NSEvent *)theEvent; +- (void)mouseEntered:(NSEvent *)theEvent; +- (void)mouseExited:(NSEvent *)theEvent; +- (void)rightMouseDown:(NSEvent *)theEvent; +- (void)rightMouseDragged:(NSEvent *)theEvent; +- (void)rightMouseUp:(NSEvent *)theEvent; +- (void)otherMouseDown:(NSEvent *)theEvent; +- (void)otherMouseDragged:(NSEvent *)theEvent; +- (void)otherMouseUp:(NSEvent *)theEvent; @end // wxPoserNSView WX_IMPLEMENT_POSER(wxPoserNSView); @@ -66,6 +78,90 @@ WX_IMPLEMENT_POSER(wxPoserNSView); [super drawRect:rect]; } +- (void)mouseDown:(NSEvent *)theEvent +{ + wxCocoaNSView *win = wxCocoaNSView::GetFromCocoa(self); + if( !win || !win->Cocoa_mouseDown(theEvent) ) + [super mouseDown:theEvent]; +} + +- (void)mouseDragged:(NSEvent *)theEvent +{ + wxCocoaNSView *win = wxCocoaNSView::GetFromCocoa(self); + if( !win || !win->Cocoa_mouseDragged(theEvent) ) + [super mouseDragged:theEvent]; +} + +- (void)mouseUp:(NSEvent *)theEvent +{ + wxCocoaNSView *win = wxCocoaNSView::GetFromCocoa(self); + if( !win || !win->Cocoa_mouseUp(theEvent) ) + [super mouseUp:theEvent]; +} + +- (void)mouseMoved:(NSEvent *)theEvent +{ + wxCocoaNSView *win = wxCocoaNSView::GetFromCocoa(self); + if( !win || !win->Cocoa_mouseMoved(theEvent) ) + [super mouseMoved:theEvent]; +} + +- (void)mouseEntered:(NSEvent *)theEvent +{ + wxCocoaNSView *win = wxCocoaNSView::GetFromCocoa(self); + if( !win || !win->Cocoa_mouseEntered(theEvent) ) + [super mouseEntered:theEvent]; +} + +- (void)mouseExited:(NSEvent *)theEvent +{ + wxCocoaNSView *win = wxCocoaNSView::GetFromCocoa(self); + if( !win || !win->Cocoa_mouseExited(theEvent) ) + [super mouseExited:theEvent]; +} + +- (void)rightMouseDown:(NSEvent *)theEvent +{ + wxCocoaNSView *win = wxCocoaNSView::GetFromCocoa(self); + if( !win || !win->Cocoa_rightMouseDown(theEvent) ) + [super rightMouseDown:theEvent]; +} + +- (void)rightMouseDragged:(NSEvent *)theEvent +{ + wxCocoaNSView *win = wxCocoaNSView::GetFromCocoa(self); + if( !win || !win->Cocoa_rightMouseDragged(theEvent) ) + [super rightMouseDragged:theEvent]; +} + +- (void)rightMouseUp:(NSEvent *)theEvent +{ + wxCocoaNSView *win = wxCocoaNSView::GetFromCocoa(self); + if( !win || !win->Cocoa_rightMouseUp(theEvent) ) + [super rightMouseUp:theEvent]; +} + +- (void)otherMouseDown:(NSEvent *)theEvent +{ + wxCocoaNSView *win = wxCocoaNSView::GetFromCocoa(self); + if( !win || !win->Cocoa_otherMouseDown(theEvent) ) + [super otherMouseDown:theEvent]; +} + +- (void)otherMouseDragged:(NSEvent *)theEvent +{ + wxCocoaNSView *win = wxCocoaNSView::GetFromCocoa(self); + if( !win || !win->Cocoa_otherMouseDragged(theEvent) ) + [super otherMouseDragged:theEvent]; +} + +- (void)otherMouseUp:(NSEvent *)theEvent +{ + wxCocoaNSView *win = wxCocoaNSView::GetFromCocoa(self); + if( !win || !win->Cocoa_otherMouseUp(theEvent) ) + [super otherMouseUp:theEvent]; +} + @end // implementation wxPoserNSView @interface wxNSViewNotificationObserver : NSObject -- 2.45.2