SunQuest
 
       XML
  Home arrow XML arrow Back to XUL: Completing the JavaScript Log...
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  
Dedicated Servers  
Actuate Whitepapers 
VeriSign Whitepapers 
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: Completing the JavaScript Logic
By: Dan Wellman
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2006-02-13

    Table of Contents:
  • Back to XUL: Completing the JavaScript Logic
  • Defining a Function
  • The Help Menu
  • The About Window
  • Making the Toolbar Work
  • Finishing up the Functions

  • 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
     
    Iron Speed
     
    ADVERTISEMENT

    Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    Back to XUL: Completing the JavaScript Logic


    (Page 1 of 6 )

    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.
    A downloadable file for this article is available here.

    The Edit menu is at this stage very basic, having just Copy, Paste and Cut actions to script.  As before, we are going to have to use XPCOM to enable this.  Compared to some of the previous functions we have used, the first one is relatively simple.  First, declare the function and get the editor element:

    function copyToClip() {

      var editor = document.getElementById('mainContent');

    In order to copy some text from the editor, some text will need to be selected and you will need to obtain whatever is selected:

    var selected = editor.contentDocument.getSelection();

    Once you have the selection, it is simple to copy this to the OS clipboard using the copy() method, but to do this, you need to get the interface that supports it, which is the nsIPlaintextEditor.  Once you have the interface, you can call the method and close the function:

    editor = editor.getEditor(editor.contentWindow).QueryInterface
    (Components.interfaces.nsIPlaintextEditor);
      editor.copy(selected);

    }

    There’s no need to use the CI constant to save on code as only one interface is used in this operation.

    More XML Articles
    More By Dan Wellman


       · Hi,This article follows on neatly from the last and shows you the code needed to...
     

    XML ARTICLES

    - 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
    - Creating an XUL App Installer
    - Overlays in XUL
    - Skinning Your Custom XUL Applications


    Iron Speed





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