Instance Property


The receiver’s location in the base coordinate system of the associated window.


var locationInWindow: NSPoint { get }


For non-mouse events the return value of this method is undefined.

With NSMouseMoved and possibly other events, the event can have a nil window (that is, the window property contains nil). In this case, locationInWindow returns the event location in screen coordinates.

In a method of a custom view that handles mouse events, you commonly use the locationInWindow property in conjunction with the NSView method convert(_:from:)to get the mouse location in the view’s coordinate system. For example:

NSPoint event_location = theEvent.locationInWindow;
NSPoint local_point = [self convertPoint:event_location fromView:nil];

See Also

Getting General Event Information

var context: NSGraphicsContext?

The display graphics context for this event.

var timestamp: TimeInterval

The time when the event occurred in seconds since system startup.

var window: NSWindow?

The window object associated with the event.

var windowNumber: Int

The identifier for the window device associated with the event.

var eventRef: UnsafeRawPointer?

An opaque Carbon type associated with this event.

var cgEvent: CGEvent?

The Core Graphics event object corresponding to this event.