简体   繁体   中英

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

I have an NSTextField which is "read only" (not enabled, selectable nor editable). 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; the user has to drag-select to scroll.

Would an NSTextView (with enclosing scroll view) work?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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