Home arrow XML arrow Back to XUL: The Interface

Back to XUL: The Interface

This article, the second in a series about the XML variant called XUL, gets you started on creating the main interface for an application. Among other things, it covers sub-menus, toolbars, and the main content window.

Author Info:
By: Dan Wellman
Rating: 5 stars5 stars5 stars5 stars5 stars / 2
January 23, 2006
  1. · Back to XUL: The Interface
  2. · Adding the sub-menu
  3. · Don't forget the toolbar
  4. · The main content window

print this article

Back to XUL: The Interface
(Page 1 of 4 )

Okay, so you have Mozilla installed and a text editor is open and awaiting your input?  Great, let’s get started on the main interface file.

<?xml version="1.0"?>

It was XML that put the X into XUL, so the rules that apply to XML documents also apply to XUL documents.  The document must be well-formed and you need the XML declaration at the top of your file.

The top level element of XUL is the window element, which serves as a container for all other elements.  This must have the XUL namespace as an attribute:

       title=”XUL Edit Lite 1.0”

As a point of interest, the keymaster and gatekeeper used in the namespace are references to the classic movie "Ghostbusters."  Anyway, the id attribute is optional; it is used for referencing and scripting.  Other attributes include the title attribute, the value of which is displayed in the title bar at the top of the window, and the width and height attributes.  The most common screen resolution in use today is 800 x 600, so I've set the height and width attributes to these numbers.  When running XUL applications within Mozilla, they won’t have a title bar of their own.

In most Windows applications, the menu bar is right at the top of whichever application you are using.  We will follow this tradition, so your next element (or group of elements) will be a menu bar:

    <menubar id="mainmenu">
    <menu id="menuFile" label="&fileLabel;" accesskey="F">

The menu is encapsulated within a toolbox element so that it can be expanded or collapsed using a grippy.  This is not strictly necessary but I like it, and we want our application to integrate smoothly with Mozilla, so using standard features like this helps retain consistency.

As you can see, the label is an entity reference rather than the actual text that is being displayed.  This is partly because XUL experts insist that this is the proper way to do things and partly because it’s a good way of demonstrating how easy it is to provide alternative locale features, like supporting other languages.

The accesskey attribute specifies the keyboard key that can be used as a shortcut in combination with the ALT key.  Again, this is universal in Windows 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