NSCollectionView deselect multiple selection

拥有回忆 提交于 2019-12-10 11:25:07

问题


So I've been investigating on this topic now for quite a bit, but haven't found anything useful related to it. My problem is that I created an NSCollectionView that serves like an image handler, so where you can drop images, select one or even multiple images at a time and delete them if wanted. Selecting the pictures was rather easy and I achieved it with this bit of code:

func collectionView(_ collectionView: NSCollectionView, didSelectItemsAt indexPaths: Set<IndexPath>) {
        selectedCells = indexPaths
    }

If the selectedCells is changed it will update the collectionView with the respective highlight.

My problem is now deselecting them. If I click on another image or multiple images the previously selected image gets deselected, but if I click on an empty space or on another view nothing happens, here is the problem. How can I deselect the previously selected Image(s) if the view is being unfocused. I already tried the didDeselectItemsAt function but it never gets called since i'm using multiple selection. I Hope it didn't get too confusing :]

Any help would be greatly appreciated

来源:https://stackoverflow.com/questions/40472377/nscollectionview-deselect-multiple-selection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!