<!--
{
  "availability" : [
    "iOS: 17.4.0 -",
    "iPadOS: 17.4.0 -",
    "tvOS: 17.4.0 -",
    "visionOS: 1.1.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "BrowserEngineKit",
  "identifier" : "/documentation/BrowserEngineKit/BETextDocumentContext/addTextRect(_:forCharacterRange:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "BrowserEngineKit"
    ],
    "preciseIdentifier" : "c:objc(cs)BETextDocumentContext(im)addTextRect:forCharacterRange:"
  },
  "title" : "addTextRect(_:forCharacterRange:)"
}
-->

# addTextRect(_:forCharacterRange:)

Adds a rectangle that corresponds to the specified character range in the document.

```
func addTextRect(_ rect: CGRect, forCharacterRange range: NSRange)
```

## Discussion

Specify the rectangle in the view coordinates of [`textInputView`](/documentation/BrowserEngineKit/BETextInput/textInputView).

---

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)