In order to use various delegate protocols you need to have something that you can specify as a delegate. This is usually a script file such as AppDelegate in an Xcode application or CocoaAppletAppDelegate in an application created from the Cocoa-AppleScript Applet template, but it can be a any script object.
From the Script Editor, if you show the bundle contents you will see the CocoaAppletAppDelegate file - you can put stuff in there, but in this example we'll just use the default main script that the Applet provides. If you paste the following example into the main script of a new Cocoa-Applet and save it as an application, it will present a second help alert when the help button is pressed.
script MyDelegate -- this will contain any delegate methods
on alertShowHelp:alert -- handle a help button
parent's (makeAlert("The Help text.", "There is no help for you."))'s runModal()
return true -- the help request has been handled
end alertShowHelp:
end script
on run -- example
tell makeAlert("The alert text.", "The complementary message.")
its setDelegate:MyDelegate
its setShowsHelp:true
its runModal()
end tell
tell me to quit
end run
on makeAlert(messageText, infoText) -- make a simple alert object
tell current application's NSAlert's alloc's init()
its setMessageText:messageText
its setInformativeText:infoText
return it
end tell
end makeAlert
For stuff like this, using Xcode helps a bit since it has logs that you can use, although Xcode itself it quite the beast all by itself.