• 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: Hyperlinks in NSTextFields?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Hyperlinks in NSTextFields?


  • Subject: Re: Hyperlinks in NSTextFields?
  • From: Graham <email@hidden>
  • Date: Thu, 5 May 2005 13:12:15 -0400

Hi,

I also need to do this.
I am working in Java, and converted this code, but it only paints the hyperlink when the textfield is editable and not when it isn't editable. Any ideas why this would be? I am not overriding the painting in my textfield.


Thanks

Graham

On May 2, 2005, at 6:33 AM, Nicko van Someren wrote:

On 1 May 2005, at 22:34, Jonathan del Strother wrote:


I'd like to add a hyperlink into an NSTextField. Is there any way of doing so? Any alternative suggestions?


Yes. The important thing you need to do is enable rich text behaviour:
[theTextField setAllowsEditingTextAttributes: YES];


The you can just set the link attribute on the part of the text in the field you wish to make a link:
NSMutableAttributedString *t = [[theTextField attributedStringValue] mutableCopy];
NSDictionary *d = [NSDictionary dictionaryWithObject: @"http:// www.apple.com" forKey: NSLinkAttributeName];
[t addAttributes: d range: NSMakeRange(0, [t length])];
[theTextField setAttributedStringValue: t];


I hope this helps.

    Nicko

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden




_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Hyperlinks in NSTextFields?
      • From: Douglas Davidson <email@hidden>
References: 
 >Hyperlinks in NSTextFields? (From: Jonathan del Strother <email@hidden>)
 >Re: Hyperlinks in NSTextFields? (From: Nicko van Someren <email@hidden>)

  • Prev by Date: Re: Obtaining a reference to an entity's context's owner
  • Next by Date: Re: Obtaining a reference to an entity's context's owner
  • Previous by thread: Re: Hyperlinks in NSTextFields?
  • Next by thread: Re: Hyperlinks in NSTextFields?
  • Index(es):
    • Date
    • Thread