Re: Automatic scrolling in an NSTextView
Re: Automatic scrolling in an NSTextView
- Subject: Re: Automatic scrolling in an NSTextView
- From: Scott Anguish <email@hidden>
- Date: Mon, 14 Oct 2002 00:10:01 -0400
On Sunday, October 13, 2002, at 11:57 PM, Mike Brinkman wrote:
I've got an NSMutableString which I append and then set as the string
in an NSTextView as such:
[myText setString:myString];
It works like a charm, except that I have to scroll to see the
appended text. Is there a way to have the NSTextView scroll
automatically to the most recently appended text?
Well, it's actually never going to know which text has been appended,
since you add are replacing the full text each time.
I prefer
stringRepresentation=[stringToAppend
stringByAppendingString:@"\n"];
NSRange insertAtEnd=NSMakeRange([[myText textStorage] length],0);
[myText replaceCharactersInRange:insertAtEnd
withString:stringRepresentation];
[myText scrollRangeToVisible:insertAtEnd];
Note the line at the end will scroll the text to the end..
_______________________________________________
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.