Modify the background color of a row in NSTableView with Images and Buttons
Modify the background color of a row in NSTableView with Images and Buttons
- Subject: Modify the background color of a row in NSTableView with Images and Buttons
- From: Giovanni Donelli <email@hidden>
- Date: Tue, 8 Apr 2003 18:25:09 +0200
Hello folks,
I have a NSTableView which I subclass and I added few columns so that
they could hold a NSImageCell and a NSButtonCell, so now I'm able to
display images and Buttons there... actually all very simple as well as
cool...
The problem is... that I want now to add color my rows in the same ways
as iTunes does with its mp3 's playlists... alternate the color of the
lines.. so I used this delegate method:
- (void)tableView: (NSTableView *)aTableView willDisplayCell:(id)aCell
forTableColumn:(NSTableColumn *)TC row:(int)row
{
if ( (row % 2) == 0)
{
[aCell setDrawsBackground: YES];
[aCell setBackgroundColor:
[NSColor colorWithCalibratedRed: 0.9 green: 0.9 blue:1 alpha:
1.0]];
}
else
{
[aCell setDrawsBackground: NO];
[aCell setBackgroundColor: [NSColor whiteColor]];
}
}
But this works correctly with the normal text cell (which should be an
instance of NSTextFieldCell) not so well which the other cells,
actually the application crashes...
Does anybody know how to change the background of a NSButtonCell and of
NSImageCell? or a way to solve the problem I have ;-)
any advice will be very appreciated...
thanks you very much for reading me!
John
_______________________________________________
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.