On Apr 25, 2008, at 12:53 PM, Lorenzo Bevilacqua wrote:

I'm trying to get keyDown events from the contentView of a sheet window. I overrided the acceptsFirstResponder method to return YES, and added a - (void) keyDown: (NSEvent *) event.

The problem is that when the sheet becomes visible and I press a key I hear a system alert and the keyDown isn't called. I checked what's the nextResponder for that view (the window) and added keyDown method also for it, but same thing, beep and no keyDown.

I think that this problem is related to the fact that the window is modal. I found something about modal windows looking in the documentation, but the informations aren't clear.

Hi Lorenzo,

If your custom contentView is in fact the contentView of the sheet window itself, and present in the responder chain from [sheetWindow firstResponder] on up, it should be receiving those key events.

Basically, when a document-modal window (sheet) is on screen, the responder chain will ignore the window the sheet is modal (attached) to - the parent window. Events will be sent throughout the sheet window in normal responder chain fashion, and then discarded.

So, the responder chain after calling [NSApp beginSheet:sheetWindow modalForWindow:parentWindow...] will be connected like this:

1. The sheet window's firstResponder.
2. NSResponder superviews of the firstResponder.
3. The sheet window itself
4. nil, the chain ends.

I think you'll need to figure out why your custom view is not present in the responder chain of the sheet window. Make sure it is either the initialFirstResponder of the window, or (probably more common for a contentView) otherwise connected somewhere in the chain from that point upward, as described above.

Hope that helps,
Murph.

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to