Question

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)

Was it helpful?

Solution

In your NSPopUpButton subclass, try overriding canBecomeKeyView instead.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top