0

I have a collection view and each item has an image and a label. I want to click the NSCollectionViewItem or NSImage and then hide the collection view and display a completely separate view containing the details of the object that was clicked.

I cant find any documentation on how to handle click events in this situation. How is this possible? I have built out the collection view in Interface Builder so everything was done via bindings as opposed to code.

Jeff
  • 13,943
  • 11
  • 55
  • 103
  • Check this for the answer to your question: http://stackoverflow.com/questions/2541572/selection-highlight-in-nscollectionview – rakmoh Jun 18 '13 at 17:35
  • I dont see the connection between that post and handling mouse clicks. Can you explain? – Jeff Jun 18 '13 at 19:42

2 Answers2

0

@Jeff, I don't have permissions to add a comment so writing this as answer.

You can overwrite setSelection in your subclass of NSCollectionViewItem (as explained by @indragie in Selection Highlight in NSCollectionView) to track the selected item and perform an action.

Community
  • 1
  • 1
rakmoh
  • 2,953
  • 1
  • 16
  • 14
0

The solution that I went with was to not actually use an Image Well, aka NSImage. I used a button and bound the Image property to an instance of an NSImage that I exposed as a property on my model.

It was easy enough but I'm shocked more people havent been asking this question.

Jeff
  • 13,943
  • 11
  • 55
  • 103