NSView Subviews interrupting drag operation

后端 未结 2 840
粉色の甜心
粉色の甜心 2020-12-16 01:45

I have an NSView which is registered for a drag operation.

In that view I have a subclassed NSScrollView, which in itself has an NSImageView in it.

When drag

2条回答
  •  感动是毒
    2020-12-16 02:24

    Oh, thanks so much @Steven!

    Swift 4.2 and @IBOutlets:

    @IBOutlet private weak var imageView: NSImageView! {
      didSet {
        imageView.unregisterDraggedTypes()
      }
    }
    

    Long story:
    I had this NSCollectionView, which loaded a custom NSCollectionViewItem from a XIB file.

    The collection accepts drop operations (collectionView.registerForDraggedTypes([.fileURL])).
    But as soon as something was dropped into it and the custom cell was "dequeued" (makeItem(withIdentifier:for:)) -- drop operations stopped working above that specific cell.

    unregisterDraggedTypes() fixes the issue indeed.

提交回复
热议问题