Swift: 在 NSTextField 中设置插入点
Swift: Set Insertion Point in NSTextField
我有一个带有一些文本的 NSTextField "sometext"。如何以编程方式将光标放在 e 和 t 之间:"some|text"?
您需要设置您的文本字段当前编辑器选择的范围属性。像这样尝试:
textField.currentEditor()?.selectedRange = NSRange(location: 4, length: 0)
您需要调用 displayIfNeeded
textField.displayIfNeeded()
我有一个带有一些文本的 NSTextField "sometext"。如何以编程方式将光标放在 e 和 t 之间:"some|text"?
您需要设置您的文本字段当前编辑器选择的范围属性。像这样尝试:
textField.currentEditor()?.selectedRange = NSRange(location: 4, length: 0)
您需要调用 displayIfNeeded
textField.displayIfNeeded()