このカスタム+複合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で、この複合セルをホストしている場合、それは選択された行の正しい背景を取得するのに十分であるべきです。
これを自分の視点でホストしている場合は、追加作業が必要な場合があります。 (アドバイスを提供する前に、ホスト環境に関する追加の詳細を提供する必要があります)
これは私が必要としていたものです。 Jimに感謝します。 –