Dock Notification

What is the notification for clicking the app’s dock icon? Best I found was applicationWillBecomeActive but that doesn’t work if it is already active. It’s just so I can open the window if it’s closed a bit like TextEdit and most other apps.

Hi Richard,

add this into your application’s delegate class (ApplicationnameAppDelegate.applescript):


on applicationShouldHandleReopen_hasVisibleWindows_(sender)
		windowMain's makeKeyAndOrderFront_(null)
		return true
	end applicationShouldHandleReopen_hasVisibleWindows_

This works for me. windowMain is naturally the window you want to open when the Dock icon is clicked.

Thanks that’s exactly right, null should be replaced with sender really, but how come there are 2 underscores but 1 parameter?

Don’t know, can’t remember where I got this from. I haven’t thought about it since it works.

G’day

This is interesting, I was set to ask how to open a closed window from the Dock, and this might pose an answer. Trouble is, how?

This generate an error ‘can’t get display of missing value’. Anyone know how to open the window?

Regards

Santa


on applicationShouldHandleReopen_hasVisibleWindows_(sender)
		log 1
		log
		windowMain's makeKeyAndOrderFront_(null)
		log 2
		log
		windowMain's |display|
		return true
	end applicationShouldHandleReopen_hasVisibleWindows_

It’s OK

The script works if…

  1. Under the Interface Builder, select the ‘Window attributes’ inspector

  2. Deselect ‘Release when closed’

  3. Select ‘Hide on de-activate’

  4. Select ‘Visible at launch’

  5. Deselect ‘Auto recalculates view loop’

Save.

Regards

Santa

windowmain's |display|

is not needed

Out of your 4 conditions, you are not exactly correct, only release when closed unchecked is necessary.