NSTexView not updated after setString
NSTexView not updated after setString
- Subject: NSTexView not updated after setString
- From: John Nairn <email@hidden>
- Date: Fri, 04 Apr 2003 09:56:13 -0700
I have a document that displays plain text documents (possibly very
large) with an outline of major sections in a drawer (using an
NSOutlineView). The user can select to view sections of the document by
selecting them in the outline view (multiple selections are allowed).
When the user selects something from the outline view, the following
code changes the text in the main NSTextView (here called outputText)
in the following code:
// Compiled selected text into results and put it into outputText
- (void)outlineViewSelectionDidChange:(NSNotification *)notification
{
NSEnumerator *en;
NSMutableString *results=[[NSMutableString alloc]
initWithString:@""];
int select;
id obj;
// look for all selected rows
en=[resultOutline selectedRowEnumerator];
while(obj=[en nextObject])
{ select=[obj intValue];
if(select==0)
{ [outputText setString:[[self document] results]];
[results release];
return;
}
[results appendString:[[resultOutline itemAtRow:select]
content]];
[results appendString:[NSString stringWithFormat:@"\n\n"]];
}
[outputText setString:results];
[results release];
}
where the if(select==0) means the root element is selected and thus
show all the text.
THE PROBLEM:
This has always worked fine until recently when working with large
documents (few MB) in which some sections are also large (100's of kB).
In this case when a very short section replaces a large section, the
NSTextView only updates the portion of the screen needed to display the
new text. The text from the prior large section incorrectly remains
(although it is clearly not in the NSTextView because it can not be
scrolled). It only happens when the prior NSTextView string is very
large. If it is smaller, the change will show the new small text and
correctly erase all prior text even if the prior text was longer than
the new text.
------------
John Nairn (1-801-581-3413, FAX: 1-801-581-4816)
Web page:
http://www.mse.utah.edu/~nairn
_______________________________________________
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.