简体   繁体   English

Cocoa / Obj-C-如何设置禁用的NSTextField可滚动?

[英]Cocoa/Obj-C - How to set a disabled NSTextField scrollable?

I have an NSTextField which is "read only" (not enabled, selectable nor editable). 我有一个NSTextField是“只读的”(未启用,可选或可编辑)。 This field is multi-line but I would like to scroll it, is it possible? 该字段是多行,但我想滚动它,可以吗?

How can I achieve this? 我该如何实现?

The usual thing to do is make it selectable but not editable. 通常要做的是使其变为可选项,但不可编辑。 When do you want it to scroll? 您何时希望它滚动?

In the interface builder you can set the behavior of your field. 在界面构建器中,您可以设置字段的行为。 Set it to "none" 将其设置为“无”

NSTextFields don't have an enclosing scroll view, generally; 通常,NSTextFields没有封闭的滚动视图; the user has to drag-select to scroll. 用户必须拖动选择才能滚动。

Would an NSTextView (with enclosing scroll view) work? NSTextView(带有滚动视图)可以工作吗?

Otherwise, you could add some logic to resize the text field (and possibly the window) when the string is too big, but that's obviously a bit more complicated. 否则,您可以添加一些逻辑以在字符串太大时调整文本字段(可能还有窗口)的大小,但这显然要复杂一些。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM