I have a view-based NSTableView in a scroll view. I want to customized the way that selection highlighting is drawn. So, I set up a controller as a delegate of the table, and in the delegate method tableView:rowViewForRow: I provide an instance of a subclass of NSTableRowView, call it NameRowView. NameRowView overrides one method:
- (void) drawBackgroundInRect: (NSRect) dirtyRect
NSLog(@"drawBackgroundInRect %@", self);
NSRectFill( self.bounds );
The table delegate also overrides tableViewSelectionDidChange: to call setNeedsDisplay on the table. Now, if I click or use arrow keys, tableViewSelectionDidChange: does get called, but my drawBackgroundInRect: is not called.
However, if I make the window containing the table change its “main” status, then some drawBackgroundInRect: calls finally happen.
And here’s the really weird part: If I create a WindowRef for the window containing the table, like
then from then on I see the selection highlight changes immediately.