Re: NSWindow keyWindow problem
Re: NSWindow keyWindow problem
- Subject: Re: NSWindow keyWindow problem
- From: j o a r <email@hidden>
- Date: Thu, 12 Jan 2006 22:31:18 +0100
On 12 jan 2006, at 22.15, Thierry Passeron wrote:
// Give keyborad focus to the window
[w setInitialFirstResponder:v];
You're not giving the window keyboard focus here, you're setting the
content view of the window to be the first responder in the window.
Seems a bit redundant.
// Set the responder chain to include the controller
[v setNextResponder: [[[MyController alloc]init]autorelease]];
To me there are two problems here. The first is a proper bug - you're
creating an autoreleased controller that will just be deallocated at
the end of the event loop. It's not inserted into the view hierarchy,
so there is nothing holding on to it. The second problem, IMO, is
that it's backwards to set a subview to be the next responder of a
parent view. In general, the responder chain starts with some control
in the window, and goes up through the view hierarchy to the window,
window delegate, et.c.
Another suggestion: Start out with regular controls. Don't add a
custom content view, and use a regular text field in the window. Once
you've verified that it works, switch out the regular controls to
your custom ones one by one. Much easier to spot your errors that way.
j o a r
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden