Skip to content
Permalink
Browse files

handling URL data dragged in

  • Loading branch information
ejdraper committed May 19, 2015
1 parent 132750c commit 5c51eaa38693238e65c18e6d4d29975a939dfad2
Showing with 8 additions and 1 deletion.
  1. +4 −0 app/app_delegate.rb
  2. +4 −1 app/drag_and_drop_view.rb
@@ -59,4 +59,8 @@ def drag_received_for_file_paths(paths)
def drag_received_for_text(text)
@label.stringValue = "Received: #{text}"
end

def drag_received_for_url(url)
@label.stringValue = "Received: #{url}"
end
end
@@ -4,7 +4,7 @@ class DragAndDropView < NSImageView
def initWithFrame(frame)
super(frame)

self.registerForDraggedTypes([NSStringPboardType])
self.registerForDraggedTypes([NSStringPboardType, NSURLPboardType])

self
end
@@ -38,6 +38,9 @@ def performDragOperation(info)

text = info.draggingPasteboard.stringForType(NSPasteboardTypeString)
self.send_delegate_event(:drag_received_for_text, text) unless text.nil?

url = NSURL.URLFromPasteboard(info.draggingPasteboard)
self.send_delegate_event(:drag_received_for_url, url.absoluteString) unless url.nil?
end
end

0 comments on commit 5c51eaa

Please sign in to comment.
You can’t perform that action at this time.