I have a window with 3 NSTableViews and 1 NSCollectionView. The collectionview displays images. I want to be able to select one of the images and delete it using the keyboard delete key, but I can't get the collectionview to become first responder. I can select any of the tableviews and override keyDown to accept keyboard input, but that doesn't work with the collectionview. I've done this elsewhere using makeFirstResponder(_:) to force focus on the collectionview, but in that app the window only had one view. Any thoughts on what I'm doing wrong?
If you could select images in collection view or navigate in collection view using arrow keys on keyboard - usually it means that collection view is firstResponder.
So try to enable selection, check if collection view is enabled.
It is also possible that delete key is Key equivalent
read more here. If so you should override performKeyEquivalent(with: )
method to receive this type of events
Also the NSCollectionView keyDown(with: )
method do not pass the key events up the responder chain. To handle such events in it's super view you should override it in collection view by calling self.nextResponder?.keyDown(with: event)
for such events that you want to handle by yourself.