Re: NSTableView highlited text color
Re: NSTableView highlited text color
- Subject: Re: NSTableView highlited text color
- From: Dave Fernandes <email@hidden>
- Date: Wed, 5 Nov 2008 21:38:32 -0500
As yet another way to do this, you can subclass the NSTableView and
override drawRow: clipRect:
Here's my code to give a background color to expandable rows in an
outline view (like in Mail.app).
// Override to draw expandable rows with background color.
- (void)drawRow:(int)rowIndex clipRect:(NSRect)clipRect
{
id item = [self itemAtRow:rowIndex];
if ([self isExpandable:item] && [self selectedRow] != [self
rowForItem:item])
{
NSRect cellRect = [self rectOfRow:rowIndex];
[[NSColor colorWithCalibratedHue:216./360. saturation:0.16
brightness:0.95 alpha:1.] set];
[NSBezierPath fillRect:cellRect];
[[NSColor gridColor] set];
NSBezierPath* outline = [NSBezierPath bezierPath];
NSPoint point = NSMakePoint(cellRect.origin.x, cellRect.origin.y);
[outline moveToPoint:point];
point.x += cellRect.size.width;
[outline lineToPoint:point];
[outline setLineWidth:1.];
[outline stroke];
}
[super drawRow:rowIndex clipRect:clipRect];
}
On Nov 5, 2008, at 5:30 PM, Andre Masse wrote:
Hi,
When selecting a row in a NSTableView, the default highliting
(white text on blue background) doesn't work if the text is not
black. Is there a setting somewhere (in IB) or a method to
implement/override to fix that? I have a column's cell with its
foreground color set to gray and it's almost unreadable when the
row is selected. I could make my own NSTextFieldCell subclass and
override - isHighlited but would prefer not to.
Thanks,
Andre Masse
_______________________________________________
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:
40utoronto.ca
This email sent to email@hidden
_______________________________________________
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