• 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: Intelligent clipboard pasting
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Intelligent clipboard pasting


  • Subject: Re: Intelligent clipboard pasting
  • From: John Hörnkvist <email@hidden>
  • Date: Mon, 1 Oct 2001 18:18:22 +0200

On Monday, October 1, 2001, at 05:31 PM, Ken Tabb wrote:

Hi,
firstly bear in mind I've not done any clipboard / copy / paste etc.
stuff yet, so I could be talking rubbish (not for the first time...) or
asking for the world etc.

I have an Obj-C image processing app which deals with QuickTime movies
and NSImage-supported files (TIFF / PICT / PDF / JPEG etc.). It detects
humans which are walking around in the movie / image sequence.


The idea you need to pick up is pasteboard types.

When you want to put something on a pasteboard, you can put it there in many types (flavors). It's up to the application that gets it from the pasteboard to decide which data type it wants to use. If you put the same data on the pasteboard in lots of flavors, it's a good idea to use a lazy pasteboard.

NSString* MyPboardType = @"MyPboardType";

- (IBAction)copy:(id)sender
{

NSPasteboard *pboard = [NSPasteboard generalPasteboard];
NSData* data=[NSArchiver archivedDataWithRootObject:myObject];

[pboard declareTypes:[NSArray arrayWithObjects:MyPboardType, NSTIFFPboardType, NSPDFPboardType, nil] owner:self];

[pboard setData:data forType: MyPboardType];

}

- (void)pasteboard:(NSPasteboard *)sender provideDataForType:(NSString *)type
{
if ([type isEqual:NSTIFFPboardType])
{
// Get the data for MyPboardType from the pasteboard, generate tiff data from that and put it on the pasteboard.
}
}

- (void)pasteboardChangedOwner:(NSPasteboard *)sender
{
// If you keep some state related to the pasteboard, this is a good time to clean up.
}
@end

Note that pasteboards are used for more than copy&paste. While you're at it, you may want to put data on the services pasteboard, too.

Regards,
John Hornkvist

--
ToastedMarshmallow, the perfect Cocoa companion
http://www.toastedmarshmallow.com


  • Prev by Date: Re: Intelligent clipboard pasting
  • Next by Date: Re: DVD problems, was: Early thoughts on 10.1
  • Previous by thread: Re: Intelligent clipboard pasting
  • Next by thread: Re: DVD problems, was: Early thoughts on 10.1
  • Index(es):
    • Date
    • Thread