I want to configure some text before 'fully pasting' it into an NSTextField.
Is there an (easy) way to detect if the user is pasting text rather than writing it into a NSTextField in Swift?
I want to configure some text before 'fully pasting' it into an NSTextField.
Is there an (easy) way to detect if the user is pasting text rather than writing it into a NSTextField in Swift?
Why don't you check the size of the changes? You can implement the delegate method, and do something like:
func textDidChange(notification: NSNotification) {
let textField = notification.object
let newTextLength = textField.text.characters.count
...
You can now compare the length of the text with the previous one (that you'll store somewhere), if it's changing by more than 1 character, then the user is pasting something. I hope this helps.
A nstextfield does not have copy and paste functions. Those are only found in nstextview. the catch is that when a textfield is edited it opens up a textview called a fieldeditor during the editing.
See my answer here: