<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTextViewDelegate/textView(_:clickedOn:in:at:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(pl)NSTextViewDelegate(im)textView:clickedOnCell:inRect:atIndex:"
  },
  "title" : "textView(_:clickedOn:in:at:)"
}
-->

# textView(_:clickedOn:in:at:)

Sent when the user clicks a cell.

```
@MainActor optional func textView(_ textView: NSTextView, clickedOn cell: any NSTextAttachmentCellProtocol, in cellFrame: NSRect, at charIndex: Int)
```

## Parameters

`textView`

The text view sending the message.

`cell`

The cell clicked by the user.

`cellFrame`

The frame of the clicked cell.

`charIndex`

The character index of the clicked cell.

## Discussion

The delegate can use this message as its cue to perform an action or select the attachment cell’s character. `aTextView` is the first text view in a series shared by a layout manager, not necessarily the one that draws `cell`.

The delegate may subsequently receive a [`textView(_:doubleClickedOn:in:at:)`](/documentation/AppKit/NSTextViewDelegate/textView(_:doubleClickedOn:in:at:)) message if the user continues to perform a double click.

---

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)