0
votes

I have an NSPopUpButton and even a simple subclass of NSPopUpButton. In the subclass I have:

- (BOOL)acceptsFirstResponder { return YES; }

- (BOOL)refusesFirstResponder { return NO; }

Now it's easy enough to tell the window to make the button first responder, and that works on launch, but I need this to also occur as nextResponder from tabbing out of an NSTextField. Once focus is on any NSTextField, it never seems to be able to move back to the popupbutton.

What am I missing here? It seems like it should be really simple.

ANSWER: firstResponder is not the thing to use here. A subclass is needed (as I suspected) and simply needs to override the following to return YES: - (BOOL)canBecomeKeyView { return YES; } (thanks Peter Hosey)

1
Can you give us a list of controls in the window and what is set for nextResponder on each of them?Aaron Golden
Have you tried setting the previous view's nextKeyView?Peter Hosey
Contains only an NSPopUpButton and an NSTextField. Tried setting nextKeyView both in code and in IB from one to the other, no effect. Seems like only the containing window is able to set the NSPopUpButton as firstResponder. Weird.uchuugaka
@uchuugaka: Note that there is a distinction between the first responder and the key view. There is a separate canBecomeKeyView method.Peter Hosey
aha!! canBecomeKeyView {return YES;} in my subclass did the trick. Please add as answer and I'll accept it! firstResponder was not the method I was looking for.uchuugaka

1 Answers

4
votes

In your NSPopUpButton subclass, try overriding canBecomeKeyView instead.