微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

objective-c – 可可:如何使多行NSTextField?

如何使多行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;
}

原文地址:https://www.jb51.cc/c/113490.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐