Similar to this question, I'm trying to set the first responder to the first of three NSTextField
s in a very simple app. The advice there (set the Window
's first responder in interface builder) doesn't seem to apply anymore, at least not when Storyboards are involved. The Window
object does indeed have an initialFirstResponder
outlet, but I can find no way of setting it via drag, ctrl-drag etc., in either direction to/from the NSTextField.
The structure IB has provided me with comprises a Window Controller Scene (itself just an empty window) linked to a View Controller Scene (which in turn contains my set of NSTextField
s and labels).
My suspicion is that there's some default assumption/association that Xcode's baked into my app that causes the Window controller to automatically load a particular view at runtime, and that's why it's not possible to bind an initial responder that it doesn't know about at build time. Which then leaves me wondering which lifecycle call on which object is the right point to be calling self.view.window.initialFirstResponder = myTextField
before it's too late, and how to most correctly gain access to that object. viewWillAppear
or viewDidLoad
in the View Controller feel right, but neither seem to reliably have any effect (the initially active NSTextField
varies from run to run, sometimes appearing to track code changes, but either times not).
I've posted the code so far on GitHub