Back to XUL: Completing the JavaScript Logic - The About Window
(Page 4 of 6 )
The About window is even easier to code then the help system (and that was easy). All you need to do is create a new XUL file, making use of the <dialog> element to contain the program information, then create a function in the JavaScript file that calls the openDialog() method. The code for a very basic dialog window can be as follows:
<?xml version="1.0"?>
<dialog id="aboutDialog"
title="About XUL Edit Lite"
xmlns=http://www.mozilla.org/keymaster/gatekeeper/
there.is.only.xul
buttons="accept">
<description>XUL Edit Lite</description>
<description>Version: 1.0</description>
<description>Created by Dan Wellman</description>
<description>December 2005</description>
</dialog>
This is only very basic information and at this stage, without any CSS. It looks quite bad, but it should give you the general idea. It can always be tidied up and made to look good when you get around to creating a skin for the application. The JavaScript function is also very similar and should be added to the bottom of interface.js:
function lauchAbout() {
openDialog("about.xul");
}
Finally, add the oncommand handler to the relevant menu item:
<menuitem id="menuAbout" label="&aboutLabel;" accesskey="A"
key="aboutKey" oncommand="lauchAbout()"/>
Once you’ve added the calls to these functions in the main XUL file, the menubar is complete; all of the elements should now have been wired up and working. Before the application is finished however, we still need to add the code that will make the toolbar work.
Next: Making the Toolbar Work >>
More XML Articles
More By Dan Wellman