• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Detecting a paste operation in NSTextView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


  • Follow-Ups:
    • Re: Detecting a paste operation in NSTextView
      • From: Jeremy Dronfield <email@hidden>
References: 
 >Detecting a paste operation in NSTextView (From: Jeremy Dronfield <email@hidden>)

  • Prev by Date: Re: Photoshop bug,while importing images - Is anyone from Apple listening?
  • Next by Date: Re: NSURL and lingering FTP processes
  • Previous by thread: Detecting a paste operation in NSTextView
  • Next by thread: Re: Detecting a paste operation in NSTextView
  • Index(es):
    • Date
    • Thread