diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2019-10-01 05:42:25 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2019-10-01 05:42:25 +0000 |
| commit | e4950f964dffb8a0453c768ba44aa036e901a2cc (patch) | |
| tree | 2bc12fafbb4295479f700a858ef8c54c4686df58 /Common | |
| parent | Updated MacOS application (diff) | |
| download | DiligentEngine-e4950f964dffb8a0453c768ba44aa036e901a2cc.tar.gz DiligentEngine-e4950f964dffb8a0453c768ba44aa036e901a2cc.zip | |
MacOS app: added tracking area in order to always receive mouse events
Diffstat (limited to 'Common')
| -rw-r--r-- | Common/NativeApp/Apple/Source/Classes/OSX/ViewController.mm | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/Common/NativeApp/Apple/Source/Classes/OSX/ViewController.mm b/Common/NativeApp/Apple/Source/Classes/OSX/ViewController.mm index c8f9228..253f725 100644 --- a/Common/NativeApp/Apple/Source/Classes/OSX/ViewController.mm +++ b/Common/NativeApp/Apple/Source/Classes/OSX/ViewController.mm @@ -26,6 +26,18 @@ @implementation ViewController +- (void)viewDidLoad +{ + [super viewDidLoad]; + + // Add a tracking area in order to receive mouse events whenever the mouse is within the bounds of our view + NSTrackingArea *trackingArea = [[NSTrackingArea alloc] initWithRect:NSZeroRect + options:NSTrackingMouseMoved | NSTrackingInVisibleRect | NSTrackingActiveAlways + owner:self + userInfo:nil]; + [self.view addTrackingArea:trackingArea]; +} + - (void)handleEvent : (NSEvent *)theEvent { auto* view = (ViewBase*)self.view; auto* theApp = [view lockApp]; @@ -35,9 +47,6 @@ [view unlockApp]; } -- (void)mouseMove:(NSEvent *)theEvent { - [self handleEvent:theEvent]; -} - (void)mouseDown:(NSEvent *)theEvent { [self handleEvent:theEvent]; |
