如何使多行NSTextField?更新:我发现在IB特殊类型的NSTextField称为“包装文本字段”.它是多行的,但是当我想要换行时,我必须按Ctrl Enter.但是我只想按Enter来获得换行符.我该怎么做?
解决方法
没有办法仅在Interface Builder中指定此行为.您可以使用本技术说明
QA1454中所述的代理消息进行操作.
以下是技术说明中的委托消息示例:
- (BOOL)control:(NSControl*)control textView:(NSTextView*)textView doCommandBySelector:(SEL)commandSelector { BOOL result = NO; if (commandSelector == @selector(insertNewline:)) { // new line action: // always insert a line-break character and don’t cause the receiver to end editing [textView insertNewlineIgnoringFieldEditor:self]; result = YES; } else if (commandSelector == @selector(insertTab:)) { // tab action: // always insert a tab character and don’t cause the receiver to end editing [textView insertTabIgnoringFieldEditor:self]; result = YES; } return result; }