XML
  Home arrow XML arrow Page 2 - Back to XUL: The Interface
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
XML

Back to XUL: The Interface
By: Dan Wellman
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2006-01-23

    Table of Contents:
  • Back to XUL: The Interface
  • Adding the sub-menu
  • Don't forget the toolbar
  • The main content window

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Back to XUL: The Interface - Adding the sub-menu


    (Page 2 of 4 )

    So now we have the menubar; the main container for our menus; and a menu, the File menu.  Now we have to add the sub-menu that expands when the file menu is selected.  To do this, simply add a menupopup element and list the menuitems:

    <menupopup>
              <menuitem id="menuOpen" label="&openLabel;"
    accesskey="O" key="openKey"/>
              <menuitem id="menuClose" label="&closeLabel;"
    accesskey="C" key="closeKey"/>
             <menuitem id="menuSave" label="&saveLabel;"
    accesskey="S" key="saveKey"/>
              <menuseparator/>

    There are several things to note here. The menuseperator simply renders a horizontal line across the menu to visually separate menu items. We have again  specified accesskey attributes on these two menuitems, but the key attribute has also been used.  This means that in addition to using the ALT + underlined-letter short-cut, you can also specify a further keyboard shortcut to bypass the menu system altogether.  The key attribute links the menu item with an element declared outside of code for the menu itself: a keyset.

    Defining the keyset and its children separate from the menu code helps ensure your programming retains a modular formation, and for ease of reading, it is a good idea to add this near the top of the application code:

    <keyset>
        <key id="openKey" modifiers="control" key="O"/>
        <key id="closeKey" modifiers="control" key="X"/>
       <key id="saveKey" modifiers="control" key="S"/>
    </keyset>

    The ID attribute links the key to the element it is to be used with.  The modifiers and key attributes specify which special key, such as the shift or Ctrl key, and which other key combination is to be used.  As you can see, this means that when someone presses CTRL + O in this example, the Open action will be initiated.

    You may at this point be wondering how to add a second-level sub-menu to the existing menu structure.  This is very easy; you just nest in another menu element, complete with its own menupopup and menuitems:

    <menu id="menuNew" label="&newLabel;" accesskey="N">
                <menupopup>
                  <menuitem id="menuXUL" label="&xulLabel;"
    accesskey="X"/>
                  <menuitem id="menuHTM" label="&htmLabel;"
    accesskey="H"/>
                  <menuitem id="menuXML" label="&xmlLabel;"
    accesskey="M"/>
                  </menupopup>
    </menu>

    This will allow the user to specify which simple template to use.  To complete the File menu, we will provide a means for closing the editor:

    <menuseparator/>
              <menuitem id="menuExit" label="&exitLabel;"
    accesskey="E" key="exitKey"/>
          </menupopup>
    </menu>

    To complete the menubar, add the following code:

    <menu id="menuEdit" label="&editLabel;" accesskey="E">
            <menupopup>
              <menuitem id="menuCopy" label="&copyLabel;"
    accesskey="C" key="copyKey"/>
              <menuitem id="menuPaste" label="&pasteLabel;"
    accesskey="P" key="pasteKey"/>
              <menuitem id="menuCut" label="&cutLabel;" accesskey="U"
    key="cutKey"/>
            </menupopup>
          </menu>
          <menu id="menuHelp" label="&helpLabel;" accesskey="H">
            <menupopup>
              <menuitem id="menuContents" label="&helpContentsLabel;"
    accesskey="C" key="contentsKey"/>
              <menuitem id="menuAbout" label="&aboutLabel;"
    accesskey="A" key="aboutKey"/>
            </menupopup>
          </menu>
        </menubar>
    </toolbox>

    This will give the application standard Edit and Help menus.  Don’t forget to update the keyset element with the appropriate shortcut key syntax.

    More XML Articles
    More By Dan Wellman


       · Hi everyone, this article sees the creation of the interface itself; a fully...
     

    XML ARTICLES

    - 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
    - Simple Web Syndication with RSS 2.0
    - Java UI Design with an IDE
    - UI Design with Java and XML Toolkits
    - Displaying ADO Retrieved Data with XML Islan...
    - Widget Walkthrough
    - Introduction to Widgets
    - The Why and How of XML Data Islands






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
    Stay green...Green IT