문제

I have a NSTextView:

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

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


return textView;

This textView is added to subclass of NSView, in initWithFrame: I call

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

Furthermore, the [self.textView acceptsFirstResponder] == YES

But, the selection in this textView becomes gray, input not working. When I press right mouse, menu pops up, and then behavior becomes like it was expected (the blue one with working input).

Where is the problem?

도움이 되었습니까?

해결책

The reason was some view pulling first responder to itself. Just use [[self window] firstResponder] to find whom to blame in a case you have same issue.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top