Showing window by clicking on dock item

Hey all.

So I’ve created a fully working applescriptobjc application in Xcode however I would like it to function so that if I close the main window and then click the application’s icon in the dock the main window appears again. Much like in safari where a new window appears if you have no open windows.

I googled the issue and came up with this:


property myWindow : missing value

	on applicationWillBecomeActive_(aNotification)
		myWindow's makeKeyAndOrderFront_(me)
	end applicationWillBecomeActive_


However this only works if my application is not the active application. Any ideas on how to get this to work even if my application is active?

Cheers

Model: MacBook
AppleScript: Xcode 3.2.1
Browser: Safari 531.21.10
Operating System: Mac OS X (10.6)

I asked the same thing a time age XD

on applicationShouldHandleReopen_hasVisibleWindows_(sender)
	myWindow's makeKeyAndOrderFront_(sender)
	return true
end applicationShouldHandleReopen_hasVisibleWindows_

perfect! works a treat! thanks for that!