Re: Highlight color of a NSTableView row
Re: Highlight color of a NSTableView row
- Subject: Re: Highlight color of a NSTableView row
- From: Eric Gorr <email@hidden>
- Date: Thu, 10 Apr 2008 20:00:21 -0400
On Apr 10, 2008, at 6:00 AM, Cathy Shive wrote:
If you're targeting Leopard, there is an NSTableView method you can
override for this (a public one!)
-(void)highlightSelectionInClipRect:(NSRect)theClipRect
You have to actually draw the highlights, it's not simply a matter
of setting the color. If you look at the post Ben linked to, there
is sample code you can download that will show you what to do.
The problem I am having with this is that it is leaving white spaces
between the columns, which correspond to where the grid lines would be
- I have them turned off. Is there anything I can do about that?
Here is what my function looks like so far based on Ben's code...
- (void)highlightSelectionInClipRect:(NSRect)clipRect
{
NSRange aVisibleRowIndexes = [self rowsInRect:clipRect];
NSIndexSet * aSelectedRowIndexes = [self selectedRowIndexes];
int aRow = aVisibleRowIndexes.location;
int anEndRow = aRow +
aVisibleRowIndexes.length;
NSColor *aColor = [NSColor colorWithCalibratedRed:0.929 green:
0.953 blue:0.996 alpha:1.0];
[aColor set];
// draw highlight for the visible, selected rows
for (aRow; aRow < anEndRow; aRow++)
{
if([aSelectedRowIndexes containsIndex:aRow])
{
NSRect aRowRect = NSInsetRect([self rectOfRow:aRow], 2, 1);
NSRectFill(aRowRect);
}
}
}
_______________________________________________
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