Skip to content
Permalink
Browse files

adding in handling of text data drags

  • Loading branch information
ejdraper committed May 19, 2015
1 parent aafbd68 commit 132750c6e4f23f4a59913756c5bae09c3f0943a6
Showing with 15 additions and 0 deletions.
  1. +4 −0 app/app_delegate.rb
  2. +11 −0 app/drag_and_drop_view.rb
@@ -55,4 +55,8 @@ def windowDidResize(sender)
def drag_received_for_file_paths(paths)
@label.stringValue = "Received: #{paths.join(',')}"
end

def drag_received_for_text(text)
@label.stringValue = "Received: #{text}"
end
end
@@ -1,6 +1,14 @@
class DragAndDropView < NSImageView
attr_accessor :delegate

def initWithFrame(frame)
super(frame)

self.registerForDraggedTypes([NSStringPboardType])

self
end

def draggingEntered(info)
self.highlight!
NSDragOperationCopy
@@ -27,6 +35,9 @@ def performDragOperation(info)
files = info.draggingPasteboard.propertyListForType('NSFilenamesPboardType')
self.send_delegate_event(:drag_received_for_file_paths, files)
end

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

0 comments on commit 132750c

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