This is described in Technical Q & A QA1454 , which also lists the reasons why instead NSTextViewshould be used NSTextFieldin this case.
In the delimiter of the text field, you can implement the following method:
- (BOOL)control:(NSControl*)control
textView:(NSTextView*)textView
doCommandBySelector:(SEL)commandSelector
{
BOOL result = NO;
if (commandSelector == @selector(insertNewline:))
{
[textView insertNewlineIgnoringFieldEditor:self];
result = YES;
}
return result;
}
user557219
source
share