tableView Drag and drop

I will start a new topic here but my sample project is still the two-tables project using array controllers and bindings.

I have spent several days trying to understand and implement drag and drop but it seems daunting. This may be one for oBJ-C classes to handle.

I have read that you can use dataSource along side the bindings so I am doing that since the drag and drop methods are for the dataSource.

So far I have:

  1. connected the tableViews outlet to my app delegate script and selected “datasource” - I know this works because I had tried (unsuccessfully) to use dataSource methods for tableView:objectValueForTableColumn:row: and the methods were getting called.

  2. added:

on awakeFromNib()
	set aTableViewsDragTypes to NSArray's arrayWithObject_("NSFilenamesPboardType", missing value)
	log aTableViewsDragTypes
	aTableView's registerForDraggedTypes_(aTableViewsDragTypes)

the log shows:


I assume that means it sees the “register” request?

Now the tricky part. You need three methods for the table to accept a drag and drop:

on tableView_writeRowsWithIndexes_toPasteboard_(aTableView, missing value, missing value)
		log "dragOp1"
end tableView_writeRowsWithIndexes_toPasteboard_
on tableView_validateDrop_proposedRow_proposedDropOperation_(aTableView, missing value, 1, missing value)
		log "dragOp2"
		return yes
end tableView_validateDrop_proposedRow_proposedDropOperation_
on tableView_acceptDrop_row_dropOperation_(aTableView, true, missing value)
		log "dragOp3"
		return yes
end tableView_acceptDrop_row_dropOperation_

As you can see I haven’t added and code to these but hope it would at least log that they are called. maybe not.

This used to be so easy from ASS! But that is the challenge. I may attempt to create the class files for this and see if that works… hmmm

here is a pretty clear explanation:

and the docs:

Any direction here much appreciated, Rob

I haven’t really looked at this stuff, but I wonder whether you need to deal with table columns. IAC, it might be simpler to get it working with something more basic than a table first.

Well, I tried getting a text field to accept drop. I have several and the first one, as initial first responder, receives focus when you hover the mouse (the green + sign) but the others need special attention and that requires 6 methods! So I decided to try the table since it requires only three. I don’t see anything about a table column in the docs as being different from, let’s say, a text field, but I’ll do some more research.

This one seems huge.