Is there any way of getting the current cursor position in a NSTextField
? I only find answers to UITextField
which doesn't work for osx:
if let selectedRange = textField.selectedTextRange{
let cursorPosition = textField.offset(from: textField.beginningOfDocument,to: selectedRange.start)
}
Many Thanks!
Solution 1 (Obtained through NSViewController):
Solution 2 (Obtained through NSTextField):