Home arrow XML arrow Page 2 - Back to XUL: Completing the JavaScript Logic

Back to XUL: Completing the JavaScript Logic

The previous article saw us complete the File menu, making use of XPCOM to handle some of the more complex behaviors. This article will go on to discuss adding behavior to the two remaining menus, the Edit and Help menus.

Author Info:
By: Dan Wellman
Rating: 5 stars5 stars5 stars5 stars5 stars / 2
February 13, 2006
  1. · Back to XUL: Completing the JavaScript Logic
  2. · Defining a Function
  3. · The Help Menu
  4. · The About Window
  5. · Making the Toolbar Work
  6. · Finishing up the Functions

print this article

Back to XUL: Completing the JavaScript Logic - Defining a Function
(Page 2 of 6 )

Next, we need to define a function that will allow us to retrieve data from the clipboard and paste it into the document.  Because you donít need to get a selection, there is even less code than the previous function:

function pasteFromClip() {

  var editor = document.getElementById('mainContent');
  editor = editor.getEditor(editor.contentWindow).QueryInterface


You can just get the editor into the nsIPlaintextEditor interface in the same way as before, and call the paste() method on it instead.  The 1 value is just a flag for the type of text on the clipboard, in this case eEditorPlaintextMask.

The cut function is almost identical to the copy function, you just call the cut() method instead of the copy() method:

function cutToClip() {

  var editor = document.getElementById('mainContent');
  var selected = editor.contentDocument.getSelection();
  editor = editor.getEditor(editor.contentWindow).QueryInterface


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