I am trying to create a custom NSTableCellView. I subclassed NSTableCellView and I need to have a custom background color and highlight/selection color. Is there a way to do this?
Asked
Active
Viewed 2,946 times
1 Answers
2
the background as well as the selection is handled by the NSTableRowView
view. It CAN (partly) be overwritten by the cell but that's not how it should be at all.
Implement a custom rowview and return that for use behind the row you need to draw
@interface MyRowView : NSTableRowView
there you have:
- drawBackgroundInRect:
- drawDraggingDestinationFeedbackInRect:
- drawSelectionInRect:
- drawSeparatorInRect:
e.g.
@implementation MyRowView
- (void)drawSelectionInRect:(NSRect)dirtyRect {
[currentFill fillRect:dirtyRect inContext:[[NSGraphicsContext currentContext]graphicsPort]];
}
@end

Daij-Djan
- 49,552
- 17
- 113
- 135
-
the example uses CPTFill to draw a fill btw – Daij-Djan May 04 '13 at 07:57
-
the OP asked for NSTableCellView – Peter Lapisu Sep 24 '14 at 15:34
-
yes and I said: "the background as well as the selection is handled by the NSTableRowView view. It CAN (partly) be overwritten by the cell but that's not how it should be at all." – Daij-Djan Sep 24 '14 at 15:35
-
it shouldn't / can't easily be done in a tablecellView -- thats what a row view IS MADE FOR :) – Daij-Djan Sep 24 '14 at 15:36