Instance Property

locationInWindow

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

Declaration

@property(readonly) NSPoint locationInWindow;

Discussion

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 convertPoint:fromView: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

context

The display graphics context for this event.

Deprecated
timestamp

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

window

The window object associated with the event.

windowNumber

The identifier for the window device associated with the event.

eventRef

An opaque Carbon type associated with this event.

CGEvent

The Core Graphics event object corresponding to this event.