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); }