<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTextInputClient/firstRect(forCharacterRange:actualRange:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(pl)NSTextInputClient(im)firstRectForCharacterRange:actualRange:"
  },
  "title" : "firstRect(forCharacterRange:actualRange:)"
}
-->

# firstRect(forCharacterRange:actualRange:)

Returns the first logical boundary rectangle for characters in the given range.

```
func firstRect(forCharacterRange range: NSRange, actualRange: NSRangePointer?) -> NSRect
```

## Parameters

`range`

The character range whose boundary rectangle is returned.

`actualRange`

If non-`NULL`, contains the character range corresponding to the returned area if it was adjusted, for example, to a grapheme cluster boundary or characters in the first line fragment.

## Return Value

The boundary rectangle for the given range of characters, in screen coordinates. The rectangle’s  `size` value can be negative if the text flows to the left.

## Discussion

If `aRange` spans multiple lines of text in the text view, the rectangle returned is the one surrounding the characters in the first line. In that case `actualRange` contains the range covered by the first rect, so you can query all line fragments by invoking this method repeatedly. If the length of `aRange` is 0 (as it would be if there is nothing selected at the insertion point), the rectangle coincides with the insertion point, and its width is 0.

---

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)