On 23/06/2009, at 3:06 AM, iseecolors wrote:

I have a NIB with a NSView that I use to populate a Contextual View in the Main Window. I have tried to set the firstResponder from IB, from init, from awakeFromNib, and from - (BOOL)control:(NSControl *)control textShouldBeginEditing:(NSText *)fieldEditor

All of these work in 10.5 (+), but only that last works in 10.4. Unfortunately the side effect of the last is that if the user clicks on a different edit field and starts to type, the focus is on the firstResponder instead of the field the user just clicked on.

I am sure I can continue to ________ with this, but it seems like there must be a better way. It seems unlikely that 10.4 is this messed up and it will not correctly set the firstResponder.

Any hints as to what I am missing?


It's very unclear what you're trying to do.

My interpretation is that you have a custom view, and you want to make it first responder? You don't "set" first responder in most cases. Instead, implement -acceptsFirstResponder and -canBecomeKeyView to return YES, and hook up the window's initialFirstResponder outlet to your view. If there are other candidates for first responder in your window, the user should be allowed to change it, so you may also want to include your view in the key loop (nextKeyView, previousKeyView), or set this to be recalculated automatically, and make it draw a focus ring when it is first responder.

To force a specific view to become first responder, you need to use the window's -makeFirstResponder: method, not by calling - becomeFirstResponder on the view itself - but doing this is usually unnecessary as you can set the initialFirstResponder in IB.

If this is irrelevant info, then you'll need to be clearer about what you're trying to achieve, and your current code.

--Graham


_______________________________________________

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 arch...@mail-archive.com

Reply via email to