NSTableView - strange behaviour after cell text color assignment
NSTableView - strange behaviour after cell text color assignment
- Subject: NSTableView - strange behaviour after cell text color assignment
- From: Alexander Bokovikov <email@hidden>
- Date: Tue, 28 Jul 2009 00:00:11 +0600
Hi, All,
I'm trying to color my table's rows depending on some value, returning
from a function like this:
int GetState(int rowIndex);
I've searched around the Net and the only clear way I've found is to
set my AppController, as a tableView delegate and respond to the message
- (void)tableView:(NSTableView *)aTableView
willDisplayCell:(id)aCell
forTableColumn:(NSTableColumn *)aTableColumn
row:(int)rowIndex;
I've created this method as the next:
if (rowIndex == selRow)
color = [NSColor selectedTextColor];
else
switch (st = GetState(rowIndex)) {
case 1 : { color = [NSColor colorWithCalibratedRed:0
green:0
blue:0.5
alpha:1.0]; break; }
case 2 : { color = [NSColor colorWithCalibratedRed:0
green:0.5
blue:0
alpha:1.0]; break; }
case 3 : { color = [NSColor colorWithCalibratedRed:0.5
green:0
blue:0
alpha:1.0]; break; }
}
[aCell setTextColor:color];
I've got a strange effect: a new row is selected OK, when I change
selection in the tableview, but the row, which was selected, remains
being drawn with the same selected color unless reloadData will
appear. Therefore, changing selection quickly I can change color of
many rows to selected color, unless update will come. Selection bar
itself looks OK, and selected row background and text color changes
immediately, but how to update the row, which was previously selected?
I believed it will be done by my delegate method. It looks like this
method is called at some not appropriate time. Is there a solution?
Thanks.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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