Creating New Document from Clipboard -- if valid

I have a MacOS app which displays PDFs, and I want to create a New document from the Clipboard, if the clipboard contains valid graphical data.

My problem is that even if it doesn't, I still get a blank new document window. AppKit always creates a new document.

I've tried overriding the newDocument function; I've tried avoiding the built-in functions altogether.

Are there any general recommendations for going about this?

That isn't a standard operation. You'll have to invent it. It should work similarly to the "openDocument" method. If you dig into the "openDocument" method, it has a pretty good description of how the architecture opens a new document from URL and displays it. You'll just have to replicate that with a data object or pasteboard item. Once you get to the NSDocument level, there is a read method that accepts data.

Thanks. The first problem seems to be finding something that is in the FirstResponder chain that can validate the menu item if there's an image.

AppDelegate doesn't seem to work.

You'll probably need to subclass NSDocumentController.

Creating New Document from Clipboard -- if valid
 
 
Q