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

# contains(_:)

Queries whether a point lies within the text container’s region or on the region’s edge—not simply within its bounding rectangle.

```
func contains(_ point: NSPoint) -> Bool
```

## Parameters

`point`

The point in question.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if `aPoint` lies within the receiver’s region or on the region’s edge—not simply within its bounding rectangle—<doc://com.apple.documentation/documentation/Swift/false> otherwise.

## Discussion

For example, if the receiver defines a donut shape and `aPoint` lies in the hole, this method returns <doc://com.apple.documentation/documentation/Swift/false>. This method can be used for hit testing of mouse events.

The default [`NSTextContainer`](/documentation/AppKit/NSTextContainer) implementation merely checks that `aPoint` lies within its bounding rectangle.

---

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)