Re: Sheet window as firstResponder
Re: Sheet window as firstResponder
- Subject: Re: Sheet window as firstResponder
- From: Sean Murphy <email@hidden>
- Date: Sat, 26 Apr 2008 17:53:26 -0400
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 (email@hidden)
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:
This email sent to email@hidden