From fd02b2d3affe8ff3d01b9ee28e4964ae5336da34 Mon Sep 17 00:00:00 2001 From: mantognini Date: Fri, 3 Dec 2010 22:29:41 +0000 Subject: [PATCH] fix event mouse move git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1741 4e206d99-4929-0410-ac5d-dfc041789085 --- src/SFML/Window/OSX/SFOpenGLView.mm | 65 ++++++++++++++++++++++++----- 1 file changed, 55 insertions(+), 10 deletions(-) diff --git a/src/SFML/Window/OSX/SFOpenGLView.mm b/src/SFML/Window/OSX/SFOpenGLView.mm index 2a6a358d..855ca608 100644 --- a/src/SFML/Window/OSX/SFOpenGLView.mm +++ b/src/SFML/Window/OSX/SFOpenGLView.mm @@ -192,6 +192,40 @@ } +//////////////////////////////////////////////////////// +-(void)scrollWheel:(NSEvent*)theEvent +{ + if (myRequester == 0) return; + + NSPoint loc = [self convertPoint:[theEvent locationInWindow] fromView:nil]; + // Don't forget to change to SFML coord system. + float h = [[theEvent window] frame].size.height; + myRequester->MouseWheelScrolledAt([theEvent deltaY], loc.x, h - loc.y); +} + + +//////////////////////////////////////////////////////// +-(void)mouseEntered:(NSEvent*)theEvent +{ + myMouseIsIn = YES; + + if (myRequester == 0) return; + + myRequester->MouseMovedIn(); +} + + +//////////////////////////////////////////////////////// +-(void)mouseExited:(NSEvent*)theEvent +{ + myMouseIsIn = NO; + + if (myRequester == 0) return; + + myRequester->MouseMovedOut(); +} + + //////////////////////////////////////////////////////// -(void)rightMouseDown:(NSEvent*)theEvent { @@ -269,36 +303,47 @@ //////////////////////////////////////////////////////// --(void)scrollWheel:(NSEvent*)theEvent +-(void)rightMouseDragged:(NSEvent*)theEvent { if (myRequester == 0) return; + // If the event is not useful. + if (!myMouseIsIn) return; + NSPoint loc = [self convertPoint:[theEvent locationInWindow] fromView:nil]; // Don't forget to change to SFML coord system. float h = [[theEvent window] frame].size.height; - myRequester->MouseWheelScrolledAt([theEvent deltaY], loc.x, h - loc.y); + myRequester->MouseMovedAt(loc.x, h - loc.y); } //////////////////////////////////////////////////////// --(void)mouseEntered:(NSEvent*)theEvent +-(void)mouseDragged:(NSEvent*)theEvent { - myMouseIsIn = YES; - if (myRequester == 0) return; - myRequester->MouseMovedIn(); + // If the event is not useful. + if (!myMouseIsIn) return; + + NSPoint loc = [self convertPoint:[theEvent locationInWindow] fromView:nil]; + // Don't forget to change to SFML coord system. + float h = [[theEvent window] frame].size.height; + myRequester->MouseMovedAt(loc.x, h - loc.y); } //////////////////////////////////////////////////////// --(void)mouseExited:(NSEvent*)theEvent +-(void)otherMouseDragged:(NSEvent*)theEvent { - myMouseIsIn = NO; - if (myRequester == 0) return; - myRequester->MouseMovedOut(); + // If the event is not useful. + if (!myMouseIsIn) return; + + NSPoint loc = [self convertPoint:[theEvent locationInWindow] fromView:nil]; + // Don't forget to change to SFML coord system. + float h = [[theEvent window] frame].size.height; + myRequester->MouseMovedAt(loc.x, h - loc.y); }