Re: Intelligent clipboard pasting
Re: Intelligent clipboard pasting
- Subject: Re: Intelligent clipboard pasting
- From: Brian Hill <email@hidden>
- Date: Mon, 1 Oct 2001 10:52:59 -0500
On Monday, October 1, 2001, at 10:31 AM, 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.
I'd like to be able to copy the image / current frame (which is also
made
into an NSImage, so in all cases this is an NSImage) out of the app and
into AppleWorks (for instance). But I'd also like to be able to copy and
paste from within the app to another document in the same app. In this
latter instance, I'd like to be able to include extra info in the
clipboard... as well as the bitmap image, I'd like the number and
locations of humans in the image. However when I'm going to
AppleWorks, I
only want to copy the image (and not the NSArrays of human locations
etc.)
How do I determine where I'm copying from and where I'm pasting to, in
particular:
[1] When 'copy'ing in my app, do I copy everything (as if I was pasting
within the same app, with all info (image + arrays))?
[2] Do I detect (somehow) that, since 'copy'ing an image + NSArray in my
app, the app has lost focus (user changed the foreground app) and so I
should remove everything in the clipboard which isn't the image (so that
only the image is pasted into the other app). If this is the case, (a)
how do I do this and (b) if the user goes back into my app and 'paste's,
it'll only contain the image, so I guess this approach is wrong.
[3] Can you even contain more than 1 thing in the clipboard at once
(image + array of ints), or can you only do this by putting them all
in a
custom object class which you've designed to house an image + array etc.
Presumably this requires it to be an object type which other apps will
recognise?
[4] Would this work if pasted into Carbon apps too, or could I only
paste
into Cocoa apps? And classic apps (not that this is as important)?
So as you can see I've managed to confuse myself quite successfully
about
this. Thanks in advance if you can help... sorry if I've confused you
too!
In most ways, the general strategy would be the same as in OS9: put as
many 'flavors' or pasteboard types as you can onto the clipboard, and
let the receiving application(s) decide which ones it wants to use.
Don't worry about removing things from the pasteboard.
For example, I just recently added copy and paste support to one of my
applications. If you paste back into the application, you'll get the
richer program-specific representation of the data (a property list),
but if you paste into TextEdit, you'll get a plain text representation
of the same data. I did this by adding both my own program-specific data
types and a plain text (NSStringPboardType) representation to the
pasteboard when the user chooses 'copy'.
Brian
email@hidden
http://personalpages.tds.net/~brian_hill
___________________________________________________________
"Why? I came into this game for adventure - go anywhere, travel
light, get in, get out, wherever there's trouble, a man alone.
Now they've got the whole country sectioned off and you can't
move without a form. I'm the last of a breed."
-- Archibald "Harry" Tuttle, Rogue HVAC Repairman
___________________________________________________________