Getting [NSEvent mouseLocation] in view coordination system
You should be using locationInWindow
, not mouseLocation
. The docs on locationInWindow
show how to go from there:
NSPoint event_location = [theEvent locationInWindow];
NSPoint local_point = [self convertPoint:event_location fromView:nil];
Swift
override func mouseMoved(with event: NSEvent) {
let mouseLocation = event.locationInWindow
print(mouseLocation)
}