Last active
December 14, 2015 20:38
-
-
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
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 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