---
title: "hitTest(_:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nsview/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.

## Declaration

```swift
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

Return Value A view object that is the farthest descendent of aPoint.

## Discussion

Discussion This method is used primarily by an 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

### Related Documentation

- [convert(_:to:)](appkit/nsview/convert(_:to:)-6u9ir.md)

### Handling Events in the View

- [acceptsFirstMouse(for:)](appkit/nsview/acceptsfirstmouse(for:).md)
- [isMousePoint(_:in:)](appkit/nsview/ismousepoint(_:in:).md)
- [performKeyEquivalent(with:)](appkit/nsview/performkeyequivalent(with:).md)
- [rightMouseDown(with:)](appkit/nsresponder/rightmousedown(with:).md)
- [mouseDownCanMoveWindow](appkit/nsview/mousedowncanmovewindow.md)
- [inputContext](appkit/nsview/inputcontext.md)
