Guys, Ive looked around the forums and seen this asked a few times but have not found a solution that is working for me.
I have a table view with 2 columns. My datasource is being populated when files are dragged on. I am trying to have it so I can drag files in, and then reorder then by drag and reordering. I just can’t get the reorder to work.
Some of my code.
global theDataSource
on awake from nib theObject
set theDataSource to make new data source at end of data sources with properties {name:"files"}
make new data column at end of data columns of theDataSource with properties {name:"files"}
make new data column at end of data columns of theDataSource with properties {name:"file path"}
set data source of theObject to theDataSource
tell theObject to register drag types {"file names", "file paths"}
set sorted of theDataSource to false
set allows reordering of table view "tableview" of scroll view "1" of window "main" to true
end awake from nib
on drop theObject drag info dragInfo
set dataTypes to types of pasteboard of dragInfo
if "file names" is in dataTypes then
set theFiles to {}
set preferred type of pasteboard of dragInfo to "file names"
set theFiles to contents of pasteboard of dragInfo
if (count of theFiles) > 0 then
set theDataSource to data source of theObject
set update views of theDataSource to false
repeat with theItem in theFiles
set AppleScript's text item delimiters to "/"
set theparts to text items of theItem
set AppleScript's text item delimiters to ""
set theFileName to item -1 of theparts as string
set theDataRow to make new data row at end of data rows of theDataSource
set contents of data cell "file path" of theDataRow to theItem
set contents of data cell "files" of theDataRow to theFileName
end repeat
set update views of theDataSource to true
set enabled of button "submit" of window of theObject to true
end if
end if
end drop
Model: Intel PowerBook
AppleScript: xcode 3.1.4
Browser: Firefox 3.5.9
Operating System: Mac OS X (10.6)