How to determine when NSTextFieldCell isHighlighted has no focus?

Viewed 1951

I've subclassed a NSTextFieldCell (inside a NSTableView) to draw a custom foreground color when a cell (ie row) is selected (eg isHighlighted is true) and everything works fine.

The problem is when the table view loses the focus I want to draw the selected rows with a different color, how can I determine if the table view containing the cell isn't the first responder inside drawWithFrame:(NSRect)cellFrame inView:(NSView*)controlView?

My current code is

- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView*)controlView {
        NSColor* textColor = [self isHighlighted]
                 ? [NSColor alternateSelectedControlTextColor]
                 : [NSColor darkGrayColor];
}
3 Answers
Related