Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hoiberg/dropzoneview
A subclass of NSView that will make it easier to implement a NSView as dragging destination. It has extra helper functions for accepting file urls.
https://github.com/hoiberg/dropzoneview
Last synced: 22 days ago
JSON representation
A subclass of NSView that will make it easier to implement a NSView as dragging destination. It has extra helper functions for accepting file urls.
- Host: GitHub
- URL: https://github.com/hoiberg/dropzoneview
- Owner: hoiberg
- License: mit
- Created: 2015-03-03T09:29:30.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-03-03T09:59:27.000Z (almost 10 years ago)
- Last Synced: 2024-12-11T03:33:40.051Z (about 1 month ago)
- Language: Swift
- Size: 133 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DropZoneView
DropZoneView is a subclass of NSView, that will make it easier to implement a NSView as dragging destination, while keeping all the code in your NSViewController subclass. Especially if you want to accept files urls.## How to use
In interface builder, add a custom view and set its class to DropZoneView. Add a IBOutlet of this view to your NSViewController protocols.
Here is an example on how to setup the DropZoneView:dropView.registerForFileExtensions(["bmp"]) // only accept .bmp files
dropView.defaultDragOperation = .Copy
dropView.dropDelegate = self // don’t forget to add DropZoneDelegate to your ViewController subclassesIf you don’t want to accept files, just use the default `registerForDraggedTypes()` method on the dropView.
The following delegate functions are available:/// Redirect of the draggingEntered function (optional)
optional func draggingEntered(info: NSDraggingInfo) -> NSDragOperation
/// Redirect of the draggingUpdated function (optional)
optional func draggingUpdated(info: NSDraggingInfo) -> NSDragOperation
/// Redirect of the draggingExited function (optional)
optional func draggingExited(info: NSDraggingInfo)
/// Redirect of the prepareForDragOperation (optional)
optional func prepareForDragOperation(info: NSDraggingInfo) -> Bool
/// Redirect of the performDragOperations (required)
func performDragOperation(info: NSDraggingInfo) -> BoolAnd the one helper function:
class func fileUrlsFromDraggingInfo(info: NSDraggingInfo) -> [NSURL]?