Pregunta

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?

¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top