From 38b4790a89420b5b3f9c50e7025173301cd531d4 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 21 Jul 2019 15:11:43 +0200 Subject: Implement enter and leave notifications on MacOS --- pugl/pugl_osx.m | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/pugl/pugl_osx.m b/pugl/pugl_osx.m index 59f25b9..a283283 100644 --- a/pugl/pugl_osx.m +++ b/pugl/pugl_osx.m @@ -293,12 +293,34 @@ keySymToSpecial(PuglView* view, NSEvent* ev) return [self convertPoint:[event locationInWindow] fromView:nil]; } -- (void) mouseEntered:(NSEvent*)theEvent +static void +handleCrossing(PuglOpenGLView* view, NSEvent* event, const PuglEventType type) +{ + const NSPoint wloc = [view eventLocation:event]; + const NSPoint rloc = [NSEvent mouseLocation]; + const PuglEventCrossing ev = { + type, + view->puglview, + 0, + [event timestamp], + wloc.x, + view->puglview->height - wloc.y, + rloc.x, + [[NSScreen mainScreen] frame].size.height - rloc.y, + getModifiers(view->puglview, event), + PUGL_CROSSING_NORMAL + }; + puglDispatchEvent(view->puglview, (const PuglEvent*)&ev); +} + +- (void) mouseEntered:(NSEvent*)event { + handleCrossing(self, event, PUGL_ENTER_NOTIFY); } -- (void) mouseExited:(NSEvent*)theEvent +- (void) mouseExited:(NSEvent*)event { + handleCrossing(self, event, PUGL_LEAVE_NOTIFY); } - (void) mouseMoved:(NSEvent*)event -- cgit v1.2.1