I create a subclass of NSWindowController from File->New, and with the "With XIB for user interface" option checked. So I create 3 new files. Then I use Interface Builder to add exactly ONE view into the window.
And have this code in MyWindowController.m:
- (void)keyDown:(NSEvent *)theEvent{
NSLog(@"%@", theEvent);
}
- First test, add one NSButton, and run the project.
- Second test, add one WebView(NSButton deleted), and run the project.
In both tests, the window shows up correctly. But the diffrence is:
- (NSButton)I can see log output when I press keys like 'a', 'b', ..., but not the ESC key
- (WebView)I can see log output when I press keys like 'a', 'b', ..., and the ESC key as well
I change NSButton to other view type, and also my custom view, all act like the first case.
My qustion is:
- Why can't NSWindowController capture the ESC key down in the first case?
- Why the NSWindowController capture a ESC key down with WebView as first responder.
- How can NSWindowController capture the ESC key without a WebView?