Re: Formatters and TextViews
Re: Formatters and TextViews
- Subject: Re: Formatters and TextViews
- From: Douglas Davidson <email@hidden>
- Date: Mon, 10 Sep 2001 14:57:45 -0700
On Monday, September 10, 2001, at 02:45 PM, Rob Rix wrote:
Okay, this is excellent, but after an extreme amount of searching
through the documentation (both on and offline, the later with the aid
of MTLibrarian), I am unable to figure out how I'm supposed to use
NSLinkAttributeName.
You say some appropriate value...does this mean that there is a class I
should be using there, or should I just make my own class that handles
links?
Later, you mention the delegate method of NSTextView that handles
clicking on links, which seems to suggest that I should make my own
link class.
So, to reiterate, to assign the NSLinkAttributeName attribute, I should
use NSMutableAttributedString's -addAttributes:range: method on the
textStorage object of my NSTextView, and pass it a dictionary with the
entry:
key: NSLinkAttributeName
object: myGroovyLinkObject
The value for the link attribute can be whatever you choose to represent
what the link points to. For example, for hypertext links, you might
wish to use an NSURL. If you are linking to something specific to your
app, you probably will want to use a custom class. Whatever it is, it
will be sent to the text view's delegate as the "link" in the delegate's
textView:clickedOnLink:atIndex: method.
Douglas Davidson