detect modifier key on startup

Hello,
By default when the app starts no windows are shown. I’d like to have it so when the app is started and a modifier key is pressed that a window is shown.

How can I test for modifier keys on startup ?

On another note, is there a built in property for “first launch” or do I just make my own.

Cheers,

You can test for a modifier key (option/alt in this example) at launch by putting the following line in your applicationWillFinishLaunching method:

if current application's NSEvent's modifierFlags() is equal to current application's NSAlternateKeyMask then
myWindow makeKeyAndOrderFront_(me)
end if

As far as a “first launch” property, there is none that I know of, but you can use the NSUserDefaults to control the behavior of your program on subsequent launches.

Ric