John Gordon
John Gordon

Reputation: 2201

NSTextView: How to be notified when user pastes data?

I need to be notified when the user pastes data into an NSTextView in order to strip it of any disallowed data types (url links, etc). I don't want to use NSTextStorageDelegate's textStorageDidProcessEditing: because it is called when the user is just typing. How can I be notified of pastes only?

Upvotes: 0

Views: 531

Answers (2)

John Gordon
John Gordon

Reputation: 2201

implementing the NSTextStorageDelegate method: - (void)textStorageDidProcessEditing:(NSNotification *)notification captures any kind of text input. I didn't see a slow down in processing, so i'll go with this.

Upvotes: 0

Dave DeLong
Dave DeLong

Reputation: 243146

Subclass NSTextView and override the paste: method to notify you of the paste after passing on to super.

Upvotes: 1

Related Questions