Skip to content
Permalink
Browse files

additional icons for improved user feedback of drag operations

  • Loading branch information
ejdraper committed May 19, 2015
1 parent 01adfd3 commit 755e29889927e0259cc1cd900d5b55d954fc0beb
Showing with 7 additions and 6 deletions.
  1. +7 −6 app/drag_and_drop_view.rb
  2. BIN resources/text_icon.png
  3. BIN resources/url_icon.png
@@ -24,26 +24,27 @@ def prepareForDragOperation(info)

def performDragOperation(info)
if info.draggingSource != self
if NSImage.canInitWithPasteboard(info.draggingPasteboard)
image = NSImage.alloc.initWithPasteboard(info.draggingPasteboard)
else
image = NSImage.imageNamed("file_icon")
end
self.setImage(image)
image = NSImage.alloc.initWithPasteboard(info.draggingPasteboard) if NSImage.canInitWithPasteboard(info.draggingPasteboard)

if info.draggingPasteboard.types.include?('NSFilenamesPboardType')
files = info.draggingPasteboard.propertyListForType('NSFilenamesPboardType')
self.send_delegate_event(:drag_received_for_file_paths, files)
elsif info.draggingPasteboard.types.include?('WebURLsWithTitlesPboardType')
url, title = info.draggingPasteboard.propertyListForType('WebURLsWithTitlesPboardType').flatten
self.send_delegate_event(:drag_received_for_url_and_title, url, title)
image = NSImage.imageNamed("url_icon")
elsif info.draggingPasteboard.types.include?('public.url')
url = info.draggingPasteboard.propertyListForType('public.url')
self.send_delegate_event(:drag_received_for_url, url) unless url.nil?
image = NSImage.imageNamed("url_icon")
else
text = info.draggingPasteboard.stringForType(NSPasteboardTypeString)
self.send_delegate_event(:drag_received_for_text, text) unless text.nil?
image = NSImage.imageNamed("text_icon")
end

image ||= NSImage.imageNamed("file_icon")
self.setImage(image)
end
end

Binary file not shown.
BIN +1.52 KB resources/url_icon.png
Binary file not shown.

0 comments on commit 755e298

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