From 1c14a6d409e8abed6d5220af9acd56c8beefd751 Mon Sep 17 00:00:00 2001 From: omigamedev Date: Thu, 16 Feb 2017 01:47:00 +0000 Subject: [PATCH] fix mouse events in osx --- engine/main.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/engine/main.cpp b/engine/main.cpp index 5f19129..1618dec 100644 --- a/engine/main.cpp +++ b/engine/main.cpp @@ -195,17 +195,17 @@ static CVReturn MyDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTime - (void)mouseDown:(NSEvent *)theEvent { auto mouseLoc = [self convertPoint:[theEvent locationInWindow] fromView:nil]; - App::I.mouse_down(0, mouseLoc.x, mouseLoc.y); + App::I.mouse_down(0, mouseLoc.x, App::I.height - mouseLoc.y - 1); } - (void)mouseUp:(NSEvent *)theEvent { auto mouseLoc = [self convertPoint:[theEvent locationInWindow] fromView:nil]; - App::I.mouse_up(0, mouseLoc.x, mouseLoc.y); + App::I.mouse_up(0, mouseLoc.x, App::I.height - mouseLoc.y - 1); } - (void)mouseMoved:(NSEvent *)theEvent { auto mouseLoc = [self convertPoint:[theEvent locationInWindow] fromView:nil]; - App::I.mouse_move(mouseLoc.x, mouseLoc.y); + App::I.mouse_move(mouseLoc.x, App::I.height - mouseLoc.y - 1); } @end @@ -261,6 +261,8 @@ static CVReturn MyDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTime [window center]; [window makeKeyAndOrderFront:controller]; [window setContentView:view]; + [window setAcceptsMouseMovedEvents:true]; + [window makeFirstResponder:view]; controller = [[Controller alloc] initWithWindow:window];