After a bit of testing, it seems that it is “load nib” that triggers the “awake from nib” event handler. Also, out of interest, if you use an “on will open” event handler for the window, the code in that handler is executed every time the window is opened, rather than only when the nib is loaded.
Thanks! For the first time I have created multiple xibs in my applescript studio app. One xib per window. However I was struggling to get the xib not mainmenu.xib to load. Previously because I’d create windows in mainmenu.xib they’d automatically load. Now because of this post I figured out how to get separate xibs to load. Load the new xib file by adding load nib “xib file name” into on will finish launching handler of script. For the new xib file’s owner select awake from nib, this triggers the window’s awake from nib. Phew! I prefer separate xibs for windows as in the past I’ve had interface builder files become corrupt. This way I’d only lose one window.
figured it out. I was getting an applescript error -2706 which is a stack overflow. I had put the load nib command in will finish launching handler. Once I moved the load nib command in on launched the nib loaded fine. Probably the main nib or some process hasn’t finished executing so it’s not ready to load another nib.
So disregard my previous statements. If you have multiple nibs/xibs. Have a on launched handler for file’s owner of mainmenu.nib. Example: on launched handler for window.xib
on launched theObject
load nib “window”
end launched
note no .xib at end of window. That should be it. Add extra load nibs for more xibs/nibs.