Cocoa Key Window/Activate

The default Cocoa OSX project creates the main window but it doesn’t start focused or in front. What is the best way to start the application in the foreground?

call makeKeyAndOrderFront: on the window.

When? MainWindowController.windowDidLoad? AppDelegate.applicationDidFinishLaunching after the showWindow?
I’m just trying to get this to work on a plain, do-nothing demo so I can apply it to my main application.

I have a similar problem with opening a window from the main window. I launch a window from the main window and it is shown in front but it is still grayed out until it is clicked. The main window is obviously still the selected window because the list item I launch from is still highlighted. Any help is very much appreciated.

showWindow should already do this unless the window is an NSPanel and - (BOOL)becomesKeyOnlyIfNeeded returns YES (the default is NO).

I ran my program directly from finder and it is in the front like it should be. It wasn’t coming to the foreground when debugging with crossbox. No problem here.

I still can’t make my second window active when when I open it from the main window.
Main window code is basically this:
var pwindow : ProjectController := new ProjectController(pDbConnect);
pwindow.showWindow(nil);

Is there anything I can do to make it the active window?