Re: NSFont & NSTextView
Re: NSFont & NSTextView
- Subject: Re: NSFont & NSTextView
- From: Douglas Davidson <email@hidden>
- Date: Tue, 5 Mar 2002 11:42:43 -0800
On Tuesday, March 5, 2002, at 01:41 AM, Circlaeys Eric wrote:
How can I get the NSFont of a selected Text inside a TextView.
Because this :
[TextView font]
Return the font of the first character and that [TextView selectedRange]
return a range not a usabel object containing font !
There is no guarantee that the selected text uses only a single font.
To obtain the font attribute for any particular character in the text,
use [[myTextView textStorage] attribute:NSFontAttributeName atIndex:idx
effectiveRange:NULL]. For example, you could use this method with the
index [myTextView selectedRange].location to find the font attribute for
the first selected character. However, before doing this you should
first check to make sure that there are characters in the selected
range; when you see a blinking insertion point, the selected range is of
zero length, and it may point just beyond the last character of the
text, in which case there would be no next character.
For more methods to use with the text storage, see the
NSAttributedString.h headers in Foundation and AppKit, and the
NSAttributedString documentation. NSTextStorage is a subclass of
NSMutableAttributedString.
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.