NSPasteboard ops working but not DnD

67 views Asked by At

I have a document-based Cocoa application with bindings enabled; it's supposed to be a text-snippet manager. I'm developing in system version 10.9 with Xcode 6.2. The main document window has a split view with a NSTableView and a NSTextView. The model objects whose data are displayed in this table we will call Snippets, whose text is displayed in the text view; other data, like creation and modification dates, also show in the table. This array is managed by a subclass of NSArrayController, and the array is in turn an instance variable in another model object (let's call it a Shoebox that holds a collection of Snippets) that can itself be a member an array of such Shoebox objects in the document model.

I created a category on the window controller for this view with the sources for all my pasteboard ops. I have copy, cut, and paste working well. What I do is convert the data of the model object into a property list dictionary (or even an array of such dictionaries) before putting the data on the pasteboard as a Snippet type @"snpt", which is the only pasteboard type I'm declaring in this app.

I implemented tableView: writeRowsWithIndexes: toPasteboard in this pasteboard category file, made my window controller the data source for the table view, and implemented draggingEntered: and performDragOperation:.

In fact, I can pick up a table row from one open document and drag it out of the table it comes from, but I can't drop it in the snippets table for another open document, it just snaps back. With teeth showing.

This drag-and-drop design worked fine for me when I had a document window with a table view as a subview and nothing else on the window. I'm figuring the target window can't figure out what kind of data it's getting, who's sending it, or which view is supposed to receive the drop. Otherwise, I'm stumped at this point.

0

There are 0 answers