mirror of
https://github.com/qvacua/vimr.git
synced 2024-11-28 11:35:35 +03:00
38 lines
1003 B
Swift
38 lines
1003 B
Swift
/**
|
|
* Tae Won Ha - http://taewon.de - @hataewon
|
|
* See LICENSE
|
|
*/
|
|
|
|
import Cocoa
|
|
|
|
extension NeoVimView {
|
|
|
|
override public func draggingEntered(_ sender: NSDraggingInfo) -> NSDragOperation {
|
|
return isFile(sender: sender) ? .copy : NSDragOperation()
|
|
}
|
|
|
|
override public func draggingUpdated(_ sender: NSDraggingInfo) -> NSDragOperation {
|
|
return isFile(sender: sender) ? .copy : NSDragOperation()
|
|
}
|
|
|
|
override public func performDragOperation(_ sender: NSDraggingInfo) -> Bool {
|
|
guard isFile(sender: sender) else {
|
|
return false
|
|
}
|
|
|
|
guard let paths = sender.draggingPasteboard().propertyList(
|
|
forType: NSPasteboard.PasteboardType(String(kUTTypeFileURL))
|
|
) as? [String] else {
|
|
return false
|
|
}
|
|
|
|
self.open(urls: paths.map { URL(fileURLWithPath: $0) })
|
|
|
|
return true
|
|
}
|
|
}
|
|
|
|
fileprivate func isFile(sender: NSDraggingInfo) -> Bool {
|
|
return (sender.draggingPasteboard().types?.contains(NSPasteboard.PasteboardType(String(kUTTypeFileURL)))) ?? false
|
|
}
|