hide cursor on OSX

This commit is contained in:
2019-03-10 00:43:33 +01:00
parent 65872cf253
commit 5cd80f41fa
3 changed files with 23 additions and 0 deletions

View File

@@ -124,6 +124,11 @@ std::mutex task_mutex;
self = [super initWithFrame:frameRect pixelFormat:pf];
[self setPixelFormat:pf];
[self setOpenGLContext:context];
NSTrackingArea* trackingArea = [[NSTrackingArea alloc] initWithRect:frameRect
options: (NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved | NSTrackingActiveInKeyWindow )
owner:self userInfo:nil];
[self addTrackingArea:trackingArea];
return self;
}
- (void)prepareOpenGL
@@ -374,6 +379,17 @@ static CVReturn MyDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTime
App::I.mouse_move(mouseLoc.x, App::I.height - mouseLoc.y - 1, p, kEventSource::Mouse, 0);
});
}
-(void)mouseExited:(NSEvent *)event
{
self->cursor_visible = CGCursorIsVisible();
if (!self->cursor_visible)
[NSCursor unhide];
}
-(void)mouseEntered:(NSEvent *)event
{
if (!self->cursor_visible)
[NSCursor hide];
}
- (void)scrollWheel:(NSEvent *)theEvent
{
auto mouseLoc = [self convertPoint:[theEvent locationInWindow] fromView:nil];