Home arrow XML arrow Page 4 - An Introduction to XUL Part 5

The keyset element - XML

Learn about XUL, a subset of XML used to describe user interfaces, that helps you to make rich user interfaces with nothing more complicated than a text editor. In the fifth part of this series you will receive an introduction to XPCOM, the object model used by XUL, and take a close look at a basic example of the combination of Mozilla components and interfaces that make up the abstraction layer.

  1. An Introduction to XUL Part 5
  2. Buttons, JavaScript, and XPCOM
  3. The nsIFilePicker interface
  4. The keyset element
By: Dan Wellman
Rating: starstarstarstarstar / 9
June 20, 2005

print this article



One final thing you can use in the example is the keyset element. The keyset element is used to specify a key combination that someone using the application can press to select menuitems without having to navigate the menus. The keyset element contains its children, individual key elements that define the keyboard shortcuts. The key elements need an id attribute which ties in with an attribute used on the menuitem they are a shortcut for, a modifiers attribute which specifies which special key should be pressed, a key attribute which specifies the keyboard key used in conjunction with the special key, and an event that calls whichever function they should be associated with. For this example, you can use the following keyset:

  <key id="openKey" modifiers="control" key="O"
  <key id="saveKey" modifiers="control" key="S"
  <key id="exitKey" modifiers="control" key="E"

You’ll need to associate each of the keys to their respective menuitems, so add a key="openKey" attribute to the open menuitem, a key="saveKey" attribute to the save menuitem and a key="exitKey" attribute to the exit menuitem. Now save the file and access it again via Mozilla, and press Ctrl + o to bring up the open dialog. If you expand the menu yourself, you’ll see that Mozilla has added explanatory text to the relevant menuitems to advise of the keyboard shortcuts that can be used.

This article has given an introduction to the object model used by XUL and has provided a basic example of the combination of Mozilla components and interfaces that make up the abstraction layer.  There is far, far more you can do using a combination of JavaScript and the XPCOM elements, anything in fact that any full-fledged application programming language can achieve.

>>> More XML Articles          >>> More By Dan Wellman

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Google Docs and Xpath Data Functions
- 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...

Developer Shed Affiliates


Dev Shed Tutorial Topics: