Re: Color of string with link attribute
Re: Color of string with link attribute
- Subject: Re: Color of string with link attribute
- From: Douglas Davidson <email@hidden>
- Date: Thu, 17 Jun 2004 09:43:42 -0700
On Jun 17, 2004, at 1:41 AM, Jeremy Dronfield wrote:
If you're coding for 10.3, you can subclass NSTextView and override
-linkTextAttributes. Return an empty dictionary if you want the linked
text to have whatever style attributes you dictate when you create the
link, or return a dictionary containing the attributes you want all
your links to have. Or a mixture of both. For example, I have an
application which colour-codes hyperlinks according to whether they're
file:, http: or local in-application links. The
NSForegroundColorAttributeName is applied to the text when the link is
created, and -linkTextAttributes returns [NSDictionary
dictionaryWithObject:[NSCursor pointingHandCursor]
forKey:NSCursorAttributeName], which is common to all hyperlinks.
No need to subclass--just call setLinkTextAttributes: with an
appropriate dictionary.
Here is the relevant section of 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.
_______________________________________________
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.