Created
February 4, 2011 02:41
-
-
Save cyberfox/810658 to your computer and use it in GitHub Desktop.
Drag and drop destination setup using MacRuby
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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