XML
  Home arrow XML arrow Page 2 - An Introduction to XUL Part 5
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
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? 
Google.com  
XML

An Introduction to XUL Part 5
By: Dan Wellman
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 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:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log 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


    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

    - Flex Array Collection Sort and Filtering
    - The Flex Tree Control
    - Flex List Controls
    - Working with Flex and Datagrids
    - 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...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek