In a previous post I asked how to move rows around (manually rearrange the rows) in a table.
Shane quoted there was a previous example. I indeed found the basics (also in the documentation) and used it for this implementation.
I used the Florida table example.
I think the code is working, until I have to move the selected rows to their new position !
can anybody help with the remaining code.
Here is the used code:
[code]property NSData : class “NSData” of current application
property NSKeyedArchiver : class “NSKeyedArchiver” of current application
property NSKeyedUnarchiver : class “NSKeyedUnarchiver” of current application
property NSArray : class “NSArray” of current application
property NSIndexSet : class “NSIndexSet” of current application
script Coming_to_FloridaAppDelegate
property parent : class “NSObject”
property MyPrivateTableViewDataType : "MyPrivateTableViewDataType"
property tableView : missing value
property theData : missing value -- the main property; array controller binds its content array to this
property arrayController : missing value
on applicationWillFinishLaunching_(aNotification)
– set some initial data
set my theData to {{firstName:“Ray”, lastName:“Robertson”, isAlumni:true}, {firstName:“Shane”, lastName:“Stanley”, isAlumni:true}}
set newAlumni to false – sets it to a boolean
set theMonths to {“January”, “Feb”, “March”}
-- set datasource and register drag type(s)
my tableView's setDataSource_(me)
my tableView's registerForDraggedTypes_({MyPrivateTableViewDataType})
end applicationWillFinishLaunching_
on tableView_validateDrop_proposedRow_proposedDropOperation_(aTableView, info, theRow, proposedOp)
log “-------------validate drop--------------------------”
return current application’s NSDragOperationMove
end tableView_validateDrop_proposedRow_proposedDropOperation_
on tableView_writeRowsWithIndexes_toPasteboard_(aTableView, rowIndexes, pboard)
log "------------------initiate drag from table-----------------------"
log rowIndexes
set archivedData to NSKeyedArchiver's archivedDataWithRootObject_(rowIndexes)
set draggedData to NSData's dataWithData_(archivedData)
set dragTypes to NSArray's arrayWithArray_({MyPrivateTableViewDataType} as list)
pboard's declareTypes_owner_(dragTypes, me)
pboard's setData_forType_(draggedData, MyPrivateTableViewDataType)
return 1
end tableView_writeRowsWithIndexes_toPasteboard_
on tableView_acceptDrop_row_dropOperation_(aTableView, info, theRow, proposedOp)
log "------------------accept drop-----------------------"
-- get stuff from pasteboard
set pb to info's draggingPasteboard()
set rowdata to pb's dataForType_(MyPrivateTableViewDataType)
set rowIndexes to NSKeyedUnarchiver's unarchiveObjectWithData_(rowdata)
tell me to log "insertion point " & theRow
log {"rows to insert ", rowIndexes}
-- Move the specified row(s) to its(their) new location...
-- ??????
-- ??????
return 1
end tableView_acceptDrop_row_dropOperation_
end script[/code]