加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-16 05:52:11 所属栏目:百科 来源:网络整理
导读:如何使多行NSTextField?更新:我发现在IB特殊类型的NSTextField称为“包装文本字段”.它是多行的,但是当我想要换行时,我必须按Ctrl Enter.但是我只想按Enter来获得换行符.我该怎么做? 解决方法 没有办法仅在Interface Builder中指定此行为.您可以使用本技
如何使多行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;
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读