Re: scrollRangeToVisible
Re: scrollRangeToVisible
- Subject: Re: scrollRangeToVisible
- From: Douglas Davidson <email@hidden>
- Date: Fri, 11 May 2007 08:30:48 -0700
On May 10, 2007, at 5:24 AM, Gerriet M. Denkmann wrote:
I have a method:
- (void)appendLogText: (NSString *)oneLine ;
{
NSTextStorage *textStorage = [ textView textStorage ];
NSAttributedString *att = [ [ NSAttributedString alloc ]
initWithString: oneLine attributes: logAttributes ];
[ textStorage appendAttributedString: att ];
[ att release ];
[ textView scrollRangeToVisible: NSMakeRange( [ textStorage
length], 0 ) ];
}
If this method is called a few hundred of times, it becomes
incredibly slow.
The reason seems to be that scrollRangeToVisible: does a layout
each time it is called.
This is quite unneccessary, as the text view will be displayed only
at the end of the current event.
So what I need is obviously something like: (void)
justBeforeTheNextDisplayScrollRangeToVisible:(NSRange)aRange
The question has come up before, and I believe I recommended using an
NSLayoutManager delegate to detect when layout has completed. There
is likely to be some code out there specifically for this purpose;
you should look around.
Douglas Davidson
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden