在 NSTextView 中禁用编辑

Disable editing in NSTextView

我试图在 NSTextView 中禁用编辑,但似乎没有任何选项 there.All 其他类型已启用 属性 当设置为 false 时,它​​是不可编辑的,但有没有对于 NSTextView?

请不要忘记 class 继承其超类的方法。 NSTextView 的超类是 NSText。在那里你找到了方法

  • (void)setEditable:(BOOL)flag

加上评论:

Controls whether the receiver allows the user to edit its text.

对于 SWIFT 3,您需要将 Editable 设置为 false。

var isEditable: Bool A Boolean value that controls whether the text views sharing the receiver’s layout manager allow the user to edit text.

https://developer.apple.com/documentation/appkit/nstextview#overview