Follow Link at Insertion Point in NSTextView

If you ever wondered how to programmatically trigger a click on a link in a NSTextView
, here’s one way to do so. This assumes that clickable links are not stored as temporary attributes in the NSLayoutManager
, but permanently as part of the “model” in your NSTextStorage
. You can then ask the storage for the attribute at the cursor/insertion point location: