I'm trying to get the mouse location relative to the nsview.
There are at least two methods that I know of:
NSPoint mousePosition = [self.window convertScreenToBase:[NSEvent mouseLocation]];
And
NSPoint mousePosition = [self.window mouseLocationOutsideOfEventStream];
The problem with both of those methods is that self.view is null. I'm adding this view from a view controller that itself was added by another view controller. I would like to know if it's possible to get the toplevel window starting from a nsview that can be many levels below.
Edit: of course I can use:
NSWindow *window = [self valueForKeyPath:@"delegate.delegate.view.window"];
But there must be a better way.