Re: selected table row color ala itunes ? [2]
Re: selected table row color ala itunes ? [2]
- Subject: Re: selected table row color ala itunes ? [2]
- From: Fabian Lidman <email@hidden>
- Date: Tue, 16 Dec 2003 19:19:18 +0100
In iTunes, when an album is selected, the cell is drawn with a blue
shaded.
I want to do the same thing, not to draw alternate backgound color for
the table view background.
Obviously, you need to check whether the row is selected before you
draw your green rectangle (or shaded image). In your case, the code
might look like this (untested, but you'll get the idea):
-(void) drawRow: (int)rowIndex clipRect: (NSRect)clipRect {
NSString* string = [[self dataSource] tableView: self
objectValueForTableColumn: nil row: rowIndex];
NSRect* rect = [self rectOfRow: rowIndex];
NSPoint textPoint = NSMakePoint( rect.origin.x + 4 ,
rect.origin.y + 2 );
NSDictionary* attrs = [NSDictionary dictionaryWithObject: [NSFont
systemFontOfSize: 10.0] forKey: NSFontAttributeName];
if( [self isRowSelected: rowIndex] ) {
[[NSColor greenColor] set];
[NSBezierPath fillRect: rect];
[[NSColor whiteColor] set];
}
else {
[[NSColor whiteColor] set];
[NSBezierPath fillRect: rect];
[[NSColor blackColor] set];
}
[string drawAtPoint: textPoint withAttributes: attrs];
}
_______________________________________________
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.