mirror of
https://github.com/TomHarte/CLK.git
synced 2024-12-25 03:32:01 +00:00
Takes a basic stab at mouse cursor hiding.
This commit is contained in:
parent
d03a7911b5
commit
0ace189e38
@ -16,6 +16,9 @@
|
|||||||
@implementation CSOpenGLView {
|
@implementation CSOpenGLView {
|
||||||
CVDisplayLinkRef _displayLink;
|
CVDisplayLinkRef _displayLink;
|
||||||
CGSize _backingSize;
|
CGSize _backingSize;
|
||||||
|
|
||||||
|
NSTrackingArea *_mouseTrackingArea;
|
||||||
|
NSTimer *_mouseHideTimer;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)prepareOpenGL
|
- (void)prepareOpenGL
|
||||||
@ -184,4 +187,45 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
|
|||||||
return NSDragOperationLink;
|
return NSDragOperationLink;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma mark - Mouse hiding
|
||||||
|
|
||||||
|
- (void)updateTrackingAreas {
|
||||||
|
[super updateTrackingAreas];
|
||||||
|
|
||||||
|
if(_mouseTrackingArea) {
|
||||||
|
[self removeTrackingArea:_mouseTrackingArea];
|
||||||
|
}
|
||||||
|
_mouseTrackingArea =
|
||||||
|
[[NSTrackingArea alloc]
|
||||||
|
initWithRect:self.bounds
|
||||||
|
options:NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved | NSTrackingActiveWhenFirstResponder
|
||||||
|
owner:self
|
||||||
|
userInfo:nil];
|
||||||
|
[self addTrackingArea:_mouseTrackingArea];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)mouseMoved:(NSEvent *)event {
|
||||||
|
[super mouseMoved:event];
|
||||||
|
[self scheduleMouseHide];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)mouseEntered:(NSEvent *)event {
|
||||||
|
[super mouseEntered:event];
|
||||||
|
[self scheduleMouseHide];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)scheduleMouseHide {
|
||||||
|
[_mouseHideTimer invalidate];
|
||||||
|
_mouseHideTimer = [NSTimer scheduledTimerWithTimeInterval:3.0 repeats:NO block:^(NSTimer * _Nonnull timer) {
|
||||||
|
[NSCursor setHiddenUntilMouseMoves:YES];
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)mouseExited:(NSEvent *)event {
|
||||||
|
[super mouseExited:event];
|
||||||
|
|
||||||
|
[_mouseHideTimer invalidate];
|
||||||
|
_mouseHideTimer = nil;
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
Loading…
Reference in New Issue
Block a user