NSTextField overwrites itself
NSTextField overwrites itself
- Subject: NSTextField overwrites itself
- From: Mark Slater <email@hidden>
- Date: Fri, 17 May 2002 13:29:32 -0700
I'm trying to implement a window that monitors a thread. Sometimes it
all looks good, but more often than not, the NSTextFields on the window
will overwrite themselves... you can make out the current value and one
or more previous values. The thread processes data in batches, and at
the end of each batch, it sends an update notification to the window
controller class. There is generally 1-5 seconds between updates...
sometimes longer but rarely shorter... and they don't ever seem to
overlap. Is there some kind of trick in changing the text field string
that ensures only the current value is drawn and the old value is erased
first?
The Window containing the fields is set to Buffered in IB. Also, I'm not
able to turn on "Draws Background" for the NSTextFields.
Thanks in advance!
Mark
// Source code snippet.
- (void) updateStatus: (NSNotification *) notification
{
NSDictionary *statusDict = [ notification userInfo ];
printf("Update status\n");
// Disable window flushing until all fields have been updated.
[ [ self getStatusWindow ] disableFlushWindow ];
[ self
updateTextField: [ self getStatusText ]
text: [ statusDict objectForKey: threadStatusKey ] ];
[ self
updateTextField: [ self getUnfinishedImagesText ]
text: [ [ statusDict objectForKey: numUnfinishedImagesKey ]
stringValue ] ];
[ self
updateTextField: [ self getFinishedImagesText ]
text: [ [ statusDict objectForKey: numFinishedImagesKey ]
stringValue ] ];
// Enable window flushing now that all fields have been updated.
[ [ self getStatusWindow ] enableFlushWindow ];
printf(" Update status done\n");
}
/**
* Make sure the text of a text field matches the desired text.
*/
- (void) updateTextField: (NSTextField *) textField text: (NSString *)
text
{
NSString *currentText = [ textField stringValue ];
// Only change the field if the text is different.
if( ![ currentText isEqual: text ] )
{
[ textField setStringValue: text ];
}
}
_______________________________________________
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.