Learn about XUL, a subset of XML used to describe user interfaces, that helps you to make rich user interfaces with nothing more complicated than a text editor. In the fourth part of this series you will learn about dialog boxes and wizards.
So thatís the RDF file, and the wizard file is in place, but before the wizard can be accessed via chrome, you still need to add some code to another file -- the installed-chrome.txt file. This file lives in the default install directory of Mozilla. Open it up and add the location of your XUL file to the bottom (for clarity, the path to mine is C:/XUL/Chrome/mywizard.xul)
You must add a hard return after this. Now save the installed-chrome file, and from the same folder (the Mozilla chrome folder), delete the file called contents.rdf. Open Mozilla, and this file will be regenerated. Open this file in a text editor, and you should be able to find the name of XUL wizard you have just created in there. To access your wizard, in the Mozilla address bar, type the following URL:
When the cancel or finish buttons are clicked Mozilla will close; this isnít because youíre doing something wrong, but because the wizard is not being opened from another XUL window. Also, there is no functionality behind this example wizard that would pass any values back to a calling window.
Looking at the wizard through Mozilla, you might also agree that the example code in the wizard is a little difficult to distinguish from the narrative text of the wizard. I mentioned in the first article that XUL is compatible with CSS, so what you might want to do is create the following CSS file:
This needs to appear directly after the XML declaration. Once that is in place, simply add a class="codetext" attribute to each of the opening description tags that enclose a CDATA element. Run the wizard once more and see your code highlighted, emboldened and indented to facilitate easy distinguishing of the example code.
Wizards are often used to capture more complex input from a user than a simple yes or no (when a dialog window would be more appropriate). Form controls can be placed inside wizards so that if, for example, a menu item was selected, the user could be guided through a series of questions or options. Once these questions had been answered, or the options selected, the results would be passed back to the window that the menu item that originally prompted the wizard resides in. In these cases, Mozilla would remain open.
The next article will look at the creation of dialog boxes and discuss some of the more complex issues of these types of windows, such as opening or saving dialog boxes.