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

# textView(_:willDisplayToolTip:forCharacterAt:)

Returns the actual tooltip to display.

```
@MainActor optional func textView(_ textView: NSTextView, willDisplayToolTip tooltip: String, forCharacterAt characterIndex: Int) -> String?
```

## Parameters

`textView`

The text view sending the message.

`tooltip`

The proposed tooltip to display.

`characterIndex`

The location in `textView`.

## Return Value

The actual tooltip to display, or `nil` to suppress display of the tooltip.

## Discussion

The tooltip string is the value of the <doc://com.apple.documentation/documentation/Foundation/NSAttributedString/Key/toolTip> attribute at `characterIndex`.

---

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)