Re: Altering attributes of hyperlinked text
Re: Altering attributes of hyperlinked text
- Subject: Re: Altering attributes of hyperlinked text
- From: Douglas Davidson <email@hidden>
- Date: Fri, 2 Apr 2004 09:23:05 -0800
On Apr 2, 2004, at 1:29 AM, Jeremy Dronfield 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.
From the release notes:
Temporary and Link Text Attributes
Some text attributes affect glyph generation and/or layout, and some
do not. The latter include color attributes of all types, underlines
and strikethroughs, cursors, and tooltips. Only the latter are
candidates for temporary attributes on the layout manager, or for
selected or marked text attribute on the text view. Other attributes
will be ignored if they are used as temporary, selected, or marked
text attributes. In addition, there is a new set of attributes on the
text view, the link text attributes. These will be applied--that is,
to be added, overriding only existing values of the same
attributes--to link text when drawing to the screen, just as the
selected and marked text attributes are applied to selected and marked
text. The following methods have been added to NSTextView:
- (void)setLinkTextAttributes:(NSDictionary *)attributeDictionary;
- (NSDictionary *)linkTextAttributes;
For pre-Panther applications the default value is an empty dictionary,
while for Panther-linked applications the default is blue text with an
underline, and an appropriate cursor. Note that linkTextAttributes is
intended for those who wish all links to acquire certain attributes;
applications wishing to decorate different links differently can use
temporary attributes for this purpose, which will take precedence over
the corresponding link text attributes.
Alternatively, if you do not wish to use linkTextAttributes at all,
simply set the link text attributes to an empty dictionary and you will
be able to decorate your text yourself just as you like.
Douglas Davidson
_______________________________________________
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.