Home arrow XML arrow Page 3 - Overlays in XUL

Overlays in XUL

Overlays are an important aspect of XUL, but this is a subject that Iíve barely mentioned in previous articles. Overlays can be used for a variety of purposes when designing/writing XUL applications and come in either explicit or dynamic flavors. Explicit overlays are used within your own application and form the basis of code modularization.

Author Info:
By: Dan Wellman
Rating: 5 stars5 stars5 stars5 stars5 stars / 5
May 15, 2006
  1. · Overlays in XUL
  2. · Creating an overlay
  3. · Adjusting the overlay to your application
  4. · Creating a dynamic overlay

print this article

Overlays in XUL - Adjusting the overlay to your application
(Page 3 of 4 )

If you use a locale with your application and read in things like menuitem labels, you should do the same with any overlays, so in this example, I should change the menu code within the overlay file to something like:

<menuitem id="menuitem1" label="&newlabel1;"/>
<menuitem id="menuitem1" label="&newlabel2;"/>
<menuitem id="menuitem1" label="&newlabel3;"/>
<menuitem id="menuitem1" label="&newlabel4;"/>

Then create a new DTD file with the code:

<!ENTITY newlabel1 "New item 1">
<!ENTITY newlabel2 "New item 2">
<!ENTITY newlabel3 "New item 3">
<!ENTITY newlabel4 "New item 4">

This DTD file should be saved with the name newmenuOverlay.dtd to match the overlay file and should be saved in your existing locale directory.  This way, you wonít have to register the new DTD file with the chrome either; although before it can be used, youíll need to add the following DOCTYPE declaration to your newmenuOverlay.xul file:


So now, any window that needs to contain this menu can simply have the statement that imports the overlay, and an ID matched menu element (or whatever element is being overlaid), and it can make use of the overlay file.  This is also the same means by which files can be taken from Mozilla itself to cut down on the amount of coding that is required.  You know that Mozilla is going to be installed on the end users system in order for XUL to work, so when creating XUL applications for deployment, you can rely on being able to borrow elements like these from Mozilla. 

Overlays can also overlay other overlay files as well as JavaScript or CSS files, so when using Mozilla content in your own applications not only can you overlay the elements used to build the desired menus, you can also use overlays to import the functionality which can cut down massively on the amount of coding you need to do, especially when it comes to some of the complicated XPCOM interfaces that are required in order to build things like the file open/save functionality that is often required in applications.

blog comments powered by Disqus

- Open XML Finally Supported by MS Office
- XML Features Added to Two Systems
- Using Regions with XSL Formatting Objects
- Using XSL Formatting Objects
- More Schematron Features
- Schematron Patterns and Validation
- Using Schematron
- Datatypes and More in RELAX NG
- Providing Options in RELAX NG
- An Introduction to RELAX NG
- Path, Predicates, and XQuery
- Using Predicates with XQuery
- Navigating Input Documents Using Paths
- XML Basics
- Introduction to XPath

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials