XUL does not give you as many different built-in buttons as other, more powerful programming languages such as Visual Basic or C, but you have to remember that XUL is just a mark-up language. Other buttons you can use are the help and disclosure buttons, which can be used by adding them to the comma delimited list in the dialog tag. Unlike the ok and cancel buttons, these will not do anything without adding scripts for them, but there are built-in methods (ondialoghelp and ondialogdisclosure) that will let you do this easily.
Programmers that have used .NET, for example, to inherit the functionality of pre-existing classes will feel right at home here. The object model used by Mozilla is XPCOM, which stands for cross platform component object model. In order to open and save files, for example, you will need to create an instance of a component that is able to access the required functions by implementing the correct interface, which will form the basis of the next example and will draw upon some of the elements we have already worked with.
You should only need a basic window to test the functionality of the file interface needed to produce an open file dialog. The window won’t actually open or save any files because this requires more components and interfaces and is beyond the scope of this article, but the code will demonstrate how to create a standard dialog box that people can use to select files for opening. The following window, which will need to be described by a contents.rdf and accessed through Mozilla should be enough:<?xml version="1.0"?>
title="Opening and Saving Files" width="500" height="300"
<menubar id="mainmenu" grippyhidden="true">
<menu id="file" label="File" accesskey="f">
<menuitem label="Open" accesskey="o" />
<menuitem label="Save" accesskey="s"/>
<menuitem label="Exit" accesskey="e"
blog comments powered by Disqus