---
title: locationInWindow
framework: appkit
role: symbol
role_heading: Instance Property
path: appkit/nsevent/locationinwindow
---

# locationInWindow

The event location in the base coordinate system of the associated window.

## Declaration

```swift
var locationInWindow: NSPoint { get }
```

## Discussion

Discussion This property applies to mouse events. For non-mouse events the value of this property 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, this property contains the event location in screen coordinates. In a method of a custom view that handles mouse events, you commonly use this property with the convert(_:from:) method of NSView to get the mouse location in the view’s coordinate system. The following code shows how to perform this conversion. The y coordinate in the returned point starts from a base of 1, and not 0. NSPoint event_location = theEvent.locationInWindow; NSPoint local_point = [self convertPoint:event_location fromView:nil];

## See Also

### Getting general event information

- [timestamp](appkit/nsevent/timestamp.md)
- [window](appkit/nsevent/window.md)
- [windowNumber](appkit/nsevent/windownumber.md)
- [eventRef](appkit/nsevent/eventref.md)
- [cgEvent](appkit/nsevent/cgevent.md)
- [foreverDuration](appkit/nsevent/foreverduration.md)
