The previous article saw us complete the File menu, making use of XPCOM to handle some of the more complex behaviors. This article will go on to discuss adding behavior to the two remaining menus, the Edit and Help menus.
Back to XUL: Completing the JavaScript Logic - The Help Menu (Page 3 of 6 )
Now that the Edit menu is complete, we can get to work on the help menu. Creating a fully-fledged help system is beyond the scope of this article; however, there are several ways in which a competent help system could be implemented with considerable ease. Perhaps the simplest way to do this would be to set up a standard HTML page (or series of pages) that listed the functions of the editor and perhaps an installation guide. In the same way that we opened the template files earlier, we could just load the HTML help file into the document window.
This method however, does have its drawbacks; any document that is open in the text editor is replaced, and the HTML document is editable. A better way is to simply call the window.open method and open the help document in the main Mozilla browser:
function launchHelp() {
var sURL = "help.html"; var sURLName = "helpwin"; var helpwin = window.open(sURL, sURLName);
}
Add the oncommand event handler to the main XUL file and then test it out. Click on Help à Help Contents and watch in awe as Mozilla fires up and displays your help system. The example help.html file included with this article is simply to demonstrate this effect and has, in fact, no help documentation in it. You could really go to town with this, though, and add as part of the help system a guide to XUL itself; element and component descriptions; examples; and perhaps links to some of the better XUL and Mozilla Developer sites. Just do what feels right.