Help Menu

I would like make a help file that is shown in the Help viewer. How can I do this or where is it discribed?


A trip to Google returns a wealth of information:


I’ve found that the following works well to commandeer the Help Viewer app to show my help content. Since it bypasses the “official” method of using the help system and simply uses it as an html viewer, it doesn’t really work 100% correctly, though. It does not register with the help system, so your help pages do not show up in general help searches. It also prohibits you from searching all osx help using the search field, but only while viewing your unregistered page. You’ll need to hit the back button until you get to the default osx help page, from where you can search all osx registered files.

If you’re just serving up an html help page and want it to “look” authentic, you can use this method to avoid all of the complexities of registering and setting up your help files. It may be worth it for you to go the whole way, if you want full functionality.

(* Use this line to reference a static url with no invalid characters *)
set path_Help_URL to "file:///path/to/some/html/file.html"

(* Use the following lines to access urls with spaces or other escaped characters... recommended... *
set path_Help to (POSIX path of (path to me) & "Contents/Resources/Help/index.html") as string
set path_Help_URL to call method "stringByAddingPercentEscapesUsingEncoding:" of path_Help with parameter 30
set path_Help_URL to ("file://" & path_Help_URL) as string

	tell application "Help Viewer"
		handle url path_Help_URL
	end tell
on error
	open location path_Help_URL
end try

The code which is working above accepts a plain string, and assumes that you’ve provided a valid path that has no spaces or other invalid url characters in it. Since the path will always change depending on the users machine (eg. my HD is named ‘Macintosh HD’, as is many users’) the path will often have spaces in it. To account for this, cocoa provides a method for converting a string to valid percent-escaped one for use as a url. Just uncomment the part commented out above, and comment out the first line. You’ll then have to provide a method of programmatically determining the help file path, such as referencing ‘me’ and adding the path to the file in the resources folder. There are a number of methods of doing this.