1
MacOS 10.12で問題に気づきました: "Sourcelist"ハイライトスタイルのNSTableViewを作成すると、テキストセルは黒い背景を描きますテキストを黒く黒くして、実際には読めないようにします。セルスタイルのセルベースのNSTableViewの背景セルスタイルのハイライトスタイル(10.12)
他の誰かがこの問題に遭遇したか、回避策があるのだろうかと思います。
MacOS 10.12で問題に気づきました: "Sourcelist"ハイライトスタイルのNSTableViewを作成すると、テキストセルは黒い背景を描きますテキストを黒く黒くして、実際には読めないようにします。セルスタイルのセルベースのNSTableViewの背景セルスタイルのハイライトスタイル(10.12)
他の誰かがこの問題に遭遇したか、回避策があるのだろうかと思います。
私はNSTextFieldCell
をサブクラス化することで回避策を発見し、それはその場エディタとしてNSTextTextView
のサブクラスを返すようにしています。 このサブクラスはNOを返す- drawsBackground
をオーバーライドする必要があります。 初期化後にこのプロパティを設定するだけでは十分ではないようです。
@interface NonBackgroundDrawingTextView : NSTextView
@end
@implementation NonBackgroundDrawingTextView
- (BOOL)drawsBackground {
return NO;
}
@end
@interface CustomTextFieldCell : NSTextFieldCell
@end
@implementation CustomTextFieldCell
- (NSTextView *)fieldEditorForView:(NSView *)controlView {
static NSMutableDictionary* FieldEditors = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
FieldEditors = [NSMutableDictionary dictionary];
});
if (FieldEditors[@(controlView.hash)]) {
return FieldEditors[@(controlView.hash)];
}
NSTextView* textView = [[NonBackgroundDrawingTextView alloc] initWithFrame:NSZeroRect];
[textView setFieldEditor:YES];
[textView setFocusRingType:NSFocusRingTypeExterior];
FieldEditors[@(controlView.hash)] = textView;
return textView;
}
@end