I can’t seem to get my delegate handler called, userNotificationCenter_shouldPresentNotification_ never gets called. I wanted to return “no” but the notification still appeared. Oddly the code below works fine if I just put the code in the script editor but fails when its placed within applicationWillFinishLaunching of a Applescript-Cocoa app.
Any ideas?
Thanks in advance, Scott
on applicationWillFinishLaunching:(aNotification)
set theNotif to current application's NSUserNotification's alloc()'s init()
tell theNotif
setTitle_("A title")
setInformativeText_("This is some information")
setHasActionButton_(true)
setActionButtonTitle_("Ok")
setOtherButtonTitle_("Cancel")
end tell
tell current application's NSUserNotificationCenter's defaultUserNotificationCenter()
setDelegate_(me)
deliverNotification_(theNotif)
end tell
end applicationWillFinishLaunching:
on userNotificationCenter_shouldPresentNotification_(center, notification)
display dialog "userNotificationCenter_shouldPresentNotification_"
return no
end userNotificationCenter_shouldPresentNotification_
on userNotificationCenter_didActivateNotification_(center, notification)
display dialog "userNotificationCenter_didActivateNotification_"
end userNotificationCenter_didActivateNotification_