Re: Detecting a paste operation in NSTextView
Re: Detecting a paste operation in NSTextView
- Subject: Re: Detecting a paste operation in NSTextView
- From: Douglas Davidson <email@hidden>
- Date: Mon, 29 Mar 2004 10:38:47 -0800
On Mar 27, 2004, at 10:47 AM, Jeremy Dronfield wrote:
I have a situation in which I would like my text view delegate to be
able to tell whether input text is pasted or not. I'm using
-textView:shouldChangeTextInRange:replacementString: to modify input
text, and would like to be able to do something like:
- (BOOL)textView:(NSTextView *)theTextView
shouldChangeTextInRange:(NSRange)affectedCharRange
replacementString:(NSString *)replacementString
{
if (!isPasteOperation) {
// do stuff to the string and insert it
}
// leave pasted text untouched
return YES;
}
Is there an easy way of telling whether replacementString is being
typed or pasted?
You can subclass NSTextView and override
readSelectionFromPasteboard:type:. That would catch paste, paste as
rich/plain text, drag and drop of text, dragging in of files, pasting
rulers, etc. Alternatively, you could override insertText:, which is
the funnel point for insertion by typing.
Douglas Davidson
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.