Re:Altering attributes of hyperlinked text
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.