<!--
{
  "availability" : [
    "iOS: 17.4.0 -",
    "iPadOS: 17.4.0 -",
    "tvOS: 17.4.0 -",
    "visionOS: 1.1.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "BrowserEngineKit",
  "identifier" : "/documentation/BrowserEngineKit/BETextInput/requestTextRects(for:withCompletionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "BrowserEngineKit"
    ],
    "preciseIdentifier" : "c:objc(pl)BETextInput(im)requestTextRectsForString:withCompletionHandler:"
  },
  "title" : "requestTextRects(for:withCompletionHandler:)"
}
-->

# requestTextRects(for:withCompletionHandler:)

Gathers context for the presentation of a text-related user interface.

```
func requestTextRects(for input: String, withCompletionHandler completionHandler: @escaping @Sendable ([UITextSelectionRect]) -> Void)
```

```
func requestTextRects(for input: String) async -> [UITextSelectionRect]
```

## Discussion

The system invokes your implementation of this method. The completion handler receives <doc://com.apple.documentation/documentation/UIKit/UITextSelectionRect> instances for the substring nearest to the caret that matches the given `input`.

---

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)