Re: Altering attributes of hyperlinked text
Re: Altering attributes of hyperlinked text
- Subject: Re: Altering attributes of hyperlinked text
- From: Jeremy Dronfield <email@hidden>
- Date: Fri, 2 Apr 2004 12:08:01 +0100
This is what I originally tried, and I'm afraid it doesn't work.
NSLinkAttributeName takes an undefined (id) type as its value class,
containing the URL, the blue colour and underline. Using existing
methods for adding attributes to NSMutableAttributedString, it appears
to be impossible to override these appearance attributes. So what I
need to be able to do is manipulate the default values used at the
point before the link attribute is added to the text. So far I can't
see any way to do this.
-Jeremy
On 2 Apr 2004, at 11:19 am, Sunil wrote:
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.
b 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.
b 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.