Home arrow XML arrow Page 4 - 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 - The main content window
(Page 4 of 4 )

Finally, we come to the main content window.  Compared with the rest of the elements, the code needed is extremely minimal:

<editor id="mainContent" editortype="text" type="content-

The editor element has more functionality than most of the rest of the application added together, yet it takes the least amount of code.  Many XUL elements have a good deal of functionality built into them, which from a developerís point of view is excellent because it cuts down dramatically on the size of the application and the time it takes to program.

The editortype can be either HTML or text; for this project, this is of course set to text.  The type is set to content-primary to make it the default window; this is needed for closing the current editor window easily (which is discussed later in this series, in article four).  Before you can use the editor as an editor, a point to remember is that it must be made editable first. 

For reference, the entire keyset at the top of the code should now appear thus:

    <key id="openKey" modifiers="control" key="O"/>
    <key id="closeKey" modifiers="control" key="X"/>
    <key id="saveKey" modifiers="control" key="S"/>
    <key id="exitKey" modifiers="control" keycode="F"/>
    <key id="copyKey" modifiers="control" key="C"/>
    <key id="pasteKey" modifiers="control" key="V"/>
    <key id="cutKey" modifiers="control" keycode="VK_DELETE"/>
    <key id="contentsKey" modifiers="control" key="H"/>
    <key id="aboutKey" modifiers="control" key="A"/>

The cut keyboard shortcut is declared using a non-letter reference, which is usually a VK_ prefix, followed by the full name of the key you want to use.

So this is all of the code we need to describe our application in full. Donít expect it to do anything within Mozilla at this stage -- in fact, donít even expect it to load.  You need to create the DTD file containing the entity references before the file will even get parsed properly. Once this has been done, you can at least view the interface, but you still need to create the RDF file, register the new chrome in the chrome registry, and write the JavaScript logic before it will work. 

In all honesty, weíve taken some shortcuts here; most application developers would spend a lot more time in the planning phase. Those of you educated to degree level will probably have heard of JSP or Jackson Structured Programming (among other things).  This is a method of programming whereby the logic of each of the many processes that occur within the application are mapped out visually using flow-chart style icons.  Personally, I donít think that level of detail is required for such a small program written in such an intuitive language.  At the very least however, Iím sure that in a production environment the functions would first be written in pseudo-code.  I left this out also because this is a tutorial and Iím basically telling you what to do.

It has been fairly easy so far to create an attractive interface, not unlike creating a simple web page.  The next article will go on to show you how to get the interface registered with chrome, how to create the descriptive RDF file and where to put the DTD to generate all of the display text.

DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

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-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials