The Drag/Drop Pasteboard Nightmare

  • I have an application which I am trying to update to use the new pasteboard
    protocols, NSDragSession, etc.  The new version requires Lion.  Drag/drop
    has been an absolute nightmare.  The main windows have to handle a large
    number of drop types, plus there is a separate library with its own coredata
    database which must also be able to store and provide a large number of
    types. The pasteboard handlers are monsters, which I have tried to parse out
    into more manageable chunks.  My first level approach it to try to identify
    pasteboard objects which conform to the new protocols or have been placed
    into an NSPasteboardItem.  The latter is being successfully used for private
    data types.  (Can¹t use the read/write object protocols because these are
    managed objects and require a custom unarchiver.  Yes, I¹ve filed an
    enhancement request about this.)

    Text handling has been especially difficult.  I try to drag in text from
    MSWord (2008) or TextEdit, and have all kinds of issues.  Apparently MS not
    only posts an RTF, but an image or a PDF of the text.
    ³canReadObjectForClasses² determines it has an NSImage class and I end up
    with a text image, not the text, which I would like to get or convert to an
    NSAttributedString.  Somehow, it gets recognized as an NSImage object and
    attempts to use it as such.

    Although the application is for Lion, obviously, I still want it to work
    with pre-Lion apps.  That means the application has to handle everything,
    old and new, and somehow come up with the best handler for whatever is on
    the pasteboard.  It ain¹t easy.  It might help if there were a pasteboard
    guide somewhere with suggestions and examples for how to handle complex
    pasteboards using both new and old techniques. If anyone has some words of
    wisdom on how to better attack this, they would be greatly appreciated.
previous month june 2012 next month
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30  
Go to today