Skip to content

Instantly share code, notes, and snippets.

@cyberfox
Created February 4, 2011 02:41
Show Gist options
  • Save cyberfox/810658 to your computer and use it in GitHub Desktop.
Save cyberfox/810658 to your computer and use it in GitHub Desktop.
Drag and drop destination setup using MacRuby
class TableViewDataSource
def awakeFromNib
view.registerForDraggedTypes(
NSArray.arrayWithObjects("BookmarkDictionaryListPboardType", "MozURLType",
NSFilenamesPboardType, NSURLPboardType, NSStringPboardType, nil))
end
def tableView(aView, validateDrop:info, proposedRow:row, proposedDropOperation:op)
NSDragOperationEvery
end
def tableView(aView, acceptDrop:info, row:row, dropOperation:op)
pboard = info.draggingPasteboard
str = pboard.stringForType("NSStringPboardType")
url_text = pboard.stringForType("public.utf8-plain-text")
url = pboard.stringForType("public.url") || url_text || str
url_name = pboard.stringForType("public.url-name")
url_html = pboard.stringForType("public.html")
# Do something with the dropped URL
# ...
# Need to acknowledge the data was dropped successfully, and give appropriate UI feedback
return true
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment