<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSView/hitTest(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSView(im)hitTest:"
  },
  "title" : "hitTest(_:)"
}
-->

# hitTest(_:)

Returns the farthest descendant of the view in the view hierarchy (including itself) that contains a specified point, or `nil` if that point lies completely outside the view.

```
func hitTest(_ point: NSPoint) -> NSView?
```

## Parameters

`point`

A point that is in the coordinate system of the view’s superview, not of the view itself.

## Return Value

A view object that is the farthest descendent of `aPoint`.

## Discussion

This method is used primarily by an [`NSWindow`](/documentation/AppKit/NSWindow) object to determine which view should receive a mouse-down event. You’d rarely need to invoke this method, but you might want to override it to have a view object hide mouse-down events from its subviews. This method ignores hidden views.

## See Also

[`convert(_:to:)`](/documentation/AppKit/NSView/convert(_:to:)-6u9ir)

Converts a point from the view’s coordinate system to that of a given view.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)