0

I recently got my NSCollectionView worked in the way, that it handles section the right way. I reached this by adding a binding with the Model Key Path "selected". This action hides a blue view, that shows a selection to the user. The Problem is, that i can't deselect my NSCollectionViewItem by clicking outside the image in the view, which is lowest view in the hierarchy of my NSCollectionViewItem. It also didn't deselect the itemView when I'm clicking out of my CollectionView. I tried to get it worked by subclassing my NSCollectionItemView and overriding the selected variable. But, as I said, till now I haven't reached anything to solve my Problem.

Now I'm hoping for help. What can I do?

PS: I did setup the NSControllerView with an arrayController through my MainStoryboard. And Yeah... I just started to programming with swift and cocoa for OS X. But I got some knowledge of cocoa touch. Is there any familiar way to initialise and handle actions of a NSCollectionView like an UICollectionView?

Tom Kuschka
  • 463
  • 1
  • 8
  • 17
  • What do you mean by "it handles section the right way"? Where is the blue view? Which action hides it? – Willeke Jan 14 '16 at 01:52
  • NSCollectionView had big change in 2015, for instance you could use NSCollectionViewLayout instead of binding. I am not sure which way you want to build your collectionView, but for a selection and highlight capabilities, I have a video covering this https://www.youtube.com/watch?v=RgT04gcDll4 – Harry Ng Jan 14 '16 at 03:21

1 Answers1

4

Apple has a WWDC session in 2015 talking about What's New in NSCollectionView with the new API. It talks about Selection at 36'33".

The Objective-C Sample Code CocoaSlideCollection shows the selection code in action.

I created a video tutorial on Selection as well, Sample code is available here.

Harry Ng
  • 1,070
  • 8
  • 20