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

# textView(_:clickedOnLink:at:)

Sent after the user clicks a link.

```
@MainActor optional func textView(_ textView: NSTextView, clickedOnLink link: Any, at charIndex: Int) -> Bool
```

## Parameters

`textView`

The text view sending the message.

`link`

The link that was clicked; the value of <doc://com.apple.documentation/documentation/Foundation/NSAttributedString/Key/link>.

`charIndex`

The character index where the click occurred, indexed within the text storage.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if the click was handled; otherwise, <doc://com.apple.documentation/documentation/Swift/false> to allow the next responder to handle it.

## Discussion

The delegate can use this method to handle the click on the link. It is invoked by [`clicked(onLink:at:)`](/documentation/AppKit/NSTextView/clicked(onLink:at:)).

The `charIndex` parameter is a character index somewhere in the range of the link attribute. If the user actually physically clicked the link, then it should be the character that was originally clicked. In some cases a link may be opened indirectly or programmatically, in which case a character index somewhere in the range of the link attribute is supplied.

## See Also

[`clicked(onLink:at:)`](/documentation/AppKit/NSTextView/clicked(onLink:at:))

Causes the text view to act as if the user clicked on some text with the given link as the value of a link attribute associated with the text.



---

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)