XML
  Home arrow XML arrow Page 2 - An Introduction to XUL Part 5
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
VPS Hosting 
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

An Introduction to XUL Part 5
By: Dan Wellman
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 9
    2005-06-20

    Table of Contents:
  • An Introduction to XUL Part 5
  • Buttons, JavaScript, and XPCOM
  • The nsIFilePicker interface
  • The keyset element

  • 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

    Virtual Tradeshows by Ziff Davis Enterprise - A Unique Opportunity to Connect with IT Experts, Access Information, and Gain Insight on today's Technology

    An Introduction to XUL Part 5 - Buttons, JavaScript, and XPCOM
    (Page 2 of 4 )

    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.

    JavaScript is able to perform many of the processes that lie behind an application and is used to add behavior to menus, buttons and other elements. Unfortunately, there are many things an application will need to do that are beyond the reach of JavaScript, such as working with local files. To give XUL the power that it clearly has (after all, both Mozilla and Firefox are written entirely in XUL and these are world-class browser applications), Mozilla provides an object model that allows you to implement instances of existing components of Mozilla. These components are themselves composed of interfaces that contain specific sets of functionality, which allow you to do the kind of advanced things that applications need to do in order to function.

    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"?>
    <window
      id="myApp"
      title="Opening and Saving Files" width="500" height="300"
      xmlns="http://www.mozilla.org/keymaster/gatekeeper/
        there.is.only.xul">

    <menubar id="mainmenu" grippyhidden="true">
      <menu id="file" label="File" accesskey="f">
        <menupopup id="filepop">
          <menuitem label="Open" accesskey="o" />
          <menuitem label="Save" accesskey="s"/>
          <menuseparator/>
          <menuitem label="Exit" accesskey="e"
            oncommand="window.close();"/>
        </menupopup>
      </menu>
    </menubar>

    </window>

    This will create a basic window with a basic menu in it. There are just three items in the menu, open, save and exit. There is almost no additional code required to close the window; just a simple JavaScript method that closes the current window. The oncommand event is used because we have specified accesskeys for the menu and items, which means that a user could select the exit menu item with the mouse or with the keyboard.

    More XML Articles
    More By Dan Wellman


     

       

    XML ARTICLES

    - How to Set Up Podcasting and Vodcasting
    - Creating an RSS Reader Application
    - Building an RSS File
    - An Introduction to XUL Part 6
    - An Introduction to XUL Part 5
    - An Introduction to XUL Part 4
    - An Introduction to XUL Part 3
    - An Introduction to XUL Part 2
    - An Introduction to XUL Part 1
    - XML Matters: Practical XML Data Design and M...
    - Practical XML Data Design and Manipulation f...
    - SimpleXML
    - XForms Basics, Part 3
    - XForms Basics, Part 2
    - XForms Basics

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway