Re: NSTextView scrolling issue.
Re: NSTextView scrolling issue.
- Subject: Re: NSTextView scrolling issue.
- From: Ryan Stevens <email@hidden>
- Date: Sun, 6 Nov 2005 18:37:01 -0800
On Nov 6, 2005, at 4:39 PM, Anthony Duer wrote:
Hello List,
I'm currently using a lightly subclassed NSTextView in a program
I'm developing. The subclass simply takes a
NSMutableAttributedString and appends it to it's store. Then,
depending on the enclosing scrollview, it scrolls to the bottom or
not. Here's the method:
-(void)appendStringToView: (NSMutableAttributedString *)text
{
BOOL shouldScroll = ([scroller floatValue] == 1.00) ? YES : NO;
//myStore is the subclasses' NSTextStorage, scroller is the
vertical NSScroller.
[myStore beginEditing];
[myStore appendAttributedString: text];
[myStore endEditing];
NSLog(@"f , %@", [scroller floatValue], [text string]);
if(shouldScroll)
[self scrollRangeToVisible: NSMakeRange([myStore length], 0)];
}
However, my users are seeing a rare condition where the scroller
seems to lose its place during heavy periods where text is being
sent to/from the server. For instance, if a user sends a command as
the textview is scrolling newly received text to the bottom, the
scroller starts to return values not equal to 1.00 and scroll stops
at that point. Here's a capture via the NSLog from above:
2005-11-06 16:00:27.140 Program[331] 1.000000 , >
2005-11-06 16:00:29.992 Program[331] 1.000000 , l <-- User command
2005-11-06 16:00:30.319 Program[331] 1.000000 , Text From Server
2005-11-06 16:00:30.338 Program[331] 0.200000 , Text From Server
2005-11-06 16:00:30.362 Program[331] 0.111111 , Text From Server
2005-11-06 16:00:30.424 Program[331] 0.384615 , >
2005-11-06 16:00:30.443 Program[331] 0.384615 , inv <-- User command
During this log, nothing was done to upset the scroller. The only
thing I can come up with was that since the text from the server is
being received off of a socket and the passed to the main thread
via -performSelectorOnMainThread:withObject:waitUntilDone:, some
sort of error is being produced if that method tries to fire while
appending a command.
I checked the archive and this might just be a special case, but
hopefully someone's experienced something similar.
Thanks,
~Anthony Duer
BOOL shouldScroll=([scroller floatValue] >= .999);
If they only scrolled up a teensy-tiny-bit they can do it again.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden