I have a button on my window that is set in interface builder to have the key equivalent of enter, but after switching a content view from using IKImageBrowserView to NSCollectionView, the keyEquivalent is being ignored.
From what it says in the docs:
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/EventOverview/EventArchitecture/EventArchitecture.html#//apple_ref/doc/uid/10000060i-CH3-SW10
The keyEquivalent events are handled “special” and should be pretty straight forward.
I am subclassing the NSCollectionViewItem and the view of the item but neither of these subclasses are getting the performKeyEquivalent:theEvent when I override that method.
There is a cancel button right next to the default button and is mapped to the esacpe key. Cancel continues to work, but the default button does not.
How can I tell where the enter key event is getting handled?
Edit:
I actually found the same issue in the sample app that I used to learn about NSCollectionView. I added a default button to the bottom of the window and found that return did not trigger the button but enter (fn + return) did trigger the button.
IconCollection sample app from Apple
Any ideas on what is stealing the return key event in this example?
Edit:
I posted a sample project here: https://github.com/watkyn/NSCollectionViewIssue. Why doesn’t the default button work?
ReturnandEnterare two different keys.Return(on a US keyboard) is to the right of the apostrophe key.Enteris the lower-right key on the keypad. If you are using a laptop without a numeric keypad, you getEnterby pressingfn+Return.Edit after sample code was posted
MyCollectionViewis absorbing the return/enter keystroke and not passing it up the responder chain. Add this to the implementation ofMyCollectionViewand return and enter will press the button:This may cause problems if you need MyControllerView to actually do something itself with return/enter. In that case, you can add
[super keyDown:theEvent]before[[self window] keyDown:theEvent].