1
1
mirror of https://github.com/danbee/persephone synced 2025-03-04 08:39:11 +00:00
persephone/Persephone/Controllers/AlbumViewController+NSCollectionViewDelegate.swift
Daniel Barber 52718cfcd6
WIP: Dragging works
We need to let drags through the button.
2019-09-27 13:35:48 -04:00

33 lines
949 B
Swift

//
// AlbumViewController+NSCollectionViewDelegate.swift
// Persephone
//
// Created by Daniel Barber on 2019/6/28.
// Copyright © 2019 Dan Barber. All rights reserved.
//
import AppKit
extension AlbumViewController: NSCollectionViewDelegate {
func registerForDragAndDrop(_ collectionView: NSCollectionView) {
collectionView.registerForDraggedTypes([.albumPasteboardType])
collectionView.setDraggingSourceOperationMask(.every, forLocal: true)
}
func collectionView(_ collectionView: NSCollectionView, pasteboardWriterForItemAt index: Int) -> NSPasteboardWriting? {
let album = dataSource.albums[index]
return NSPasteboardItem(
draggedAlbum: DraggedAlbum(
title: album.title,
artist: album.artist
),
ofType: .albumPasteboardType
)
}
func collectionView(_ collectionView: NSCollectionView, canDragItemsAt indexes: IndexSet, with event: NSEvent) -> Bool {
return true
}
}