I'm currently coding a text editor in swift and I'm having trouble with inserting a new line ("\n") when pressing enter/return.
By now, when pressing enter, the textField inserts a new line but ends editing with no reason.
Here is my function which will only be called when enter is pressed.
@IBAction func textFieldAction(_ sender: NSTextField) {
self.textField?.stringValue.append("\n")
self.textField?.selectAll(nil)
}
If there is more of my code needed the whole file can be found here: https://github.com/notalent/manuscript-mac/blob/master/Manuscript/Document.swift