How can I hook the NSWindow initialFirstResponder when using Storyboards in InterfaceBuilder?

I'm disappointed with the wall that seems to be using storyboards between NSWindows / NSWindowControllers and NSViews / NSViewControllers. Concrete example: What is the use of an initial FirstResponder line in an NSWindow if the entire view hierarchy is in a separate scene and cannot be specified?

I would like to make a window called "progred" initialFirstResponder a "Content View" view from the Controller View Scene, but you cannot link to IBOutlet links in different scenes. I would be happy to put the ViewController and Window on the same scene, but I can't seem to get this to work with all the drag / drop I have tried to do from one scene to another, or even trying to add a new one from the toolbar. It seems that you need to use a segue relation to assign NSViewController to NSWindow.

I googled but I don't find anything in this issue which could mean that I am missing something obvious as I am fairly new to Storiesboards as I cannot imagine I was the first to notice this :).

Scene Heirarchy

+3


source to share


1 answer


I got through this quickly (Xcode 6.3.1). IB doesn't seem to be able to do what we need, despite all the dokos and advice that says "resistance control ..." My (possible) solution / workaround was to set it in code, in viewWillAppear, from the view controller. I tried various approaches until I came across some apple doco that stated that the initialFirstResponder should be set BEFORE the window. Hope this helps.



By the way, watch out for Windows default behavior to be "recoverable" which seems to restart the (rebuilt) app with focus on the last field where the app was killed .... sigh

+3


source







All Articles