<!--
{
  "availability" : [
    "macOS: 10.5.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTextView/characterIndexForInsertion(at:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSTextView(im)characterIndexForInsertionAtPoint:"
  },
  "title" : "characterIndexForInsertion(at:)"
}
-->

# characterIndexForInsertion(at:)

Returns a character index appropriate for placing a zero-length selection for an insertion point associated with the mouse at the given point.

```
func characterIndexForInsertion(at point: NSPoint) -> Int
```

## Parameters

`point`

The point for which to return an index, in view coordinates.

## Return Value

The character index for the insertion point.

## Discussion

This method should be used for insertion points associated with mouse clicks, drag events, and so forth. For other purposes, it is better to use `NSLayoutManager` methods.

The `NSTextInput` method [`characterIndexForPoint:`](/documentation/AppKit/NSTextInput/characterIndexForPoint:) is not suitable for this role; it is intended only for uses related to text input methods.

---

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)