Skip to content

Instantly share code, notes, and snippets.

@aufi
Last active December 14, 2015 20:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aufi/5144870 to your computer and use it in GitHub Desktop.
Save aufi/5144870 to your computer and use it in GitHub Desktop.
nswindow subclass macruby drag file to open ...hours for this quite simple solution
class DragWindow < NSWindow
def awakeFromNib
self.registerForDraggedTypes [NSFilenamesPboardType]
end
def performDragOperation(sender)
filenames = sender.draggingPasteboard.propertyListForType(NSFilenamesPboardType)
p filenames.inspect
return NSApp.delegate.openFile(filenames.first) unless filenames.count == 0
false
end
def draggingEntered(sender)
p 'drag entered'
NSDragOperationCopy
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment