我在10.12下有一个基于单元格的NSOutlineView,其中包含Source-View突出显示。当我第一次点击单元格并进入编辑模式时,一切正常:
然而,一旦我开始编辑,背景会像高光一样变成蓝色。
我尝试过(没有成功):
@interface NonBackgroundDrawingTextView : NSTextView
@end
@implementation NonBackgroundDrawingTextView
-(BOOL)drawsBackground
{
return NO;
}
@end
-(NSTextView *)fieldEditorForView:(NSView *)controlView
{
NSTextView* textView = [[NonBackgroundDrawingTextView alloc] initWithFrame:NSZeroRect];
[textView setFieldEditor:YES];
[textView setFocusRingType:NSFocusRingTypeDefault];
return textView;
}
有什么想法吗?它在10.10和10.11中工作正常。
答案 0 :(得分:0)
子类 NSTextFiled,并将datacell设置为此
然后覆盖
- (void)selectWithFrame:(NSRect)aRect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)anObject start:(NSInteger)selStart length:(NSInteger)selLength
{
NSRect textFrame = [self titleRectForBounds:aRect];
[super selectWithFrame:textFrame inView:controlView editor:textObj delegate:anObject start:selStart length:selLength];
[textObj setBackgroundColor:[NSColor whiteColor]];
[textObj setDrawsBackground:YES];
}