Problem with nib handler

In my app, I’ve decided to go with two .nib files. One is a requirements window that will pop up if certain requirements on the system aren’t met. This check is done in the awake from nib handler. If the check fails, a dialog is thrown and asks the user if he wants to install requirements at this time. If so, it loads up the requirements nib. If not, it just quits.

The problem is that, whenever I reply “Yes” to the dialog, the dialog keeps coming back. When I reply no, I see in the log that the .nib gets loaded, and the requirements window pops up as it should, but in order to do that, I have to send the quit signal to the app. I’m guessing that my awake from nib handler is applying to any nib, so when the requirements window awakes from nib, it goes through the cycle again. So how do I specify which nib the requirements check should apply to? I only want it to apply to the MainMenu nib.

OK, you got 2 ways around this.

When in IB, when you click the ‘awake from nib’ checkbox in the applescript options, instead of choosing your app.applescipt file, create a new file with the ‘create new’ button at the bottom. Seperate .applescript for each window can have seperate on wake events.

THe problem is variable sharing becomes a pain.

So, simply determine which window is being loaded by checking ‘theObject’ variable’s name when the code is triggered.

(This code is typed by hand, it’s not copied from the editor, so it may not be perfect.)

On wake from nib(theObject)
If name of theObject is equal to "MainWindow" then
    --Insert Main window loading code here.
    --Every other form will  not trigger this code.
end if
end wake form nib

Hope this helps.