このカスタム+コンポジットNSCellサブクラスをどこでホストしていますか?
-setHighlighted:YESはあなたが探しているものではありません。ドキュメントから:
デフォルトでは、このメソッドは何もしません。NSButtonCellクラスは、このメソッドをオーバーライドして、NSCellLightsByBackground、NSCellLightsByContents、またはNSCellLightsByGrayで指定された外観でボタンを描画します。
通常、セルのホストビューはセルの背景スタイルを設定し、セルは描画時にそれを使用して自分自身を適切に表示します。背景スタイルをマスターセルからサブセルに伝達します。
- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{
NSRect textRect, popUpRect;
NSDivideRect(cellFrame, &textRect, &popUpRect, NSWidth(cellFrame) / 2, NSMinXEdge);
/* Draw the text cell (self) */
[super drawInteriorWithFrame: textRect inView: controlView];
/* Draw our compound popup cell - create & release every time drawn only in example */
NSPopUpButtonCell *popUpCell = [[NSPopUpButtonCell alloc] initTextCell: @"popup title"];
[popUpCell setBordered: NO];
[popUpCell setBackgroundStyle: [self backgroundStyle]];
[popUpCell drawWithFrame: popUpRect inView: controlView];
[popUpCell release];
}
この複合セルをNSTableViewでホストしている場合は、選択した行の正しい背景を取得するのに十分なはずです。
独自のビューでこれをホストしている場合は、追加の作業が必要になる場合があります。(アドバイスを提供する前に、ホスト環境に関する追加の詳細を提供する必要があります。)