• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Formatters and TextViews
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Formatters and TextViews
      • From: Rob Rix <email@hidden>
  • Prev by Date: Re: Formatters and TextViews
  • Next by Date: Drawing an NSView subview myself
  • Previous by thread: Re: Formatters and TextViews
  • Next by thread: Re: Formatters and TextViews
  • Index(es):
    • Date
    • Thread