Вопрос

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