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:
-
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.
-
added:
on awakeFromNib()
set aTableViewsDragTypes to NSArray's arrayWithObject_("NSFilenamesPboardType", missing value)
log aTableViewsDragTypes
aTableView's registerForDraggedTypes_(aTableViewsDragTypes)
the log shows:
(
NSFilenamesPboardType
)
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:
http://www.nongnu.org/gstutorial/en/ch13s04.html
Any direction here much appreciated, Rob