0

我有一个 NSTextView:

NSTextView *textView = [[NSTextView alloc] init];
[textView setTranslatesAutoresizingMaskIntoConstraints:NO];

[textView setDrawsBackground:NO];
[textView setRichText:YES];
[textView setSelectable:YES];
[textView setEditable:YES];


return textView;

这个textView被添加到NSView的子类中,在initWithFrame中:我调用

[[self window] makeFirstResponder:self.textView];

此外,该[self.textView acceptsFirstResponder] == YES

但是,这个 textView 中的选择变成灰色,输入不起作用。当我按下鼠标右键时,会弹出菜单,然后行为变得像预期的那样(带有工作输入的蓝色)。

哪里有问题?

4

1 回答 1

0

原因是一些观点将第一响应者拉到自己身上。只需使用 [[self window] firstResponder] 来查找在您遇到相同问题的情况下应该归咎于谁。

于 2013-07-29T10:21:15.520 回答