• 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:Altering attributes of hyperlinked text
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re:Altering attributes of hyperlinked text


  • Subject: Re:Altering attributes of hyperlinked text
  • From: Sunil <email@hidden>
  • Date: Fri, 2 Apr 2004 15:49:16 +0530

Is there a way to alter the default appearance attributes of
hyperlinked text in an NSTextView? The default attributes are blue
underline. I'd like to be able to colour-code different types of
hyperlink (e.g. blue for Internet URL, green for a local file and so
on). It seems to be impossible to override the default attributes at
the point when the link attribute is applied; nor can they be changed
afterwards by using the font panel.

Hi ,
I think you can change/add attributes of a text , at any time in a TextView.
To add a link with red color at the end of the existing text , here is the code. If you want to change the link color of existing text , you need to access the existing attributes and change them.


int from=[[aTextView string] length];
[editTextView insertText:urlString];
//creating array with attributes
NSMutableDictionary *linkAttributes;
linkAttributes = [NSMutableDictionary dictionaryWithObject: urlObject
forKey: NSLinkAttributeName];

[linkAttributes setObject: [NSColor redColor] forKey: NSForegroundColorAttributeName];
[linkAttributes setObject: [NSNumber numberWithBool: YES] forKey: NSUnderlineStyleAttributeName];

//adding attributes to the url string
[[editTextView textStorage] addAttributes: linkAttributes range: NSMakeRange(from,[urlString length])];

------------------------------------------------------------------------ --
Ramesh PVK
Programmer
effigent India Pvt. Ltd.
ⅱ Home : 040 27227830
: 040 31148951
------------------------------------------------------------------------ --
In a world without walls and fences, who does still need Windows and Gates ?
------------------------------------------------------------------------ --
Ramesh PVK
Programmer
effigent India Pvt. Ltd.
ⅱ Home : 040 27227830
: 040 31148951
------------------------------------------------------------------------ --
In a world without walls and fences, who does still need Windows and Gates ?
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: Altering attributes of hyperlinked text
      • From: Jeremy Dronfield <email@hidden>
  • Prev by Date: Re: Measuring length of string compared to text field
  • Next by Date: Re: Is the internet avaliable question
  • Previous by thread: Re: Altering attributes of hyperlinked text
  • Next by thread: Re: Altering attributes of hyperlinked text
  • Index(es):
    • Date
    • Thread