Only do copy when the editor has focus. clipboardonfocus
authorAlex Iskander <alex@tpsitulsa.com>
Fri, 18 Sep 2009 10:09:50 -0500
branchclipboardonfocus
changeset 2670 1a6cdb90863a18576870599decf0d3d948eeedac
parent 2669 2718c2601e9ffad5a086320a342d52071e24b3e1
child 2671 90f1efe632b2c53351da8828c5e813421bc502f3
child 2672 bb3defff6165f9bfeacfbd5e57d63e9977bcab75
push id1131
push userkdangoor@mozilla.com
push dateFri, 18 Sep 2009 15:31:56 +0000
Only do copy when the editor has focus.
frontend/js/bespin/editor/clipboard.js
--- a/frontend/js/bespin/editor/clipboard.js
+++ b/frontend/js/bespin/editor/clipboard.js
@@ -90,17 +90,17 @@ dojo.mixin(bespin.editor.clipboard, {
 
 dojo.declare("bespin.editor.clipboard.DOMEvents", null, {
     install: function(editor) {
         // * Defensively stop doing copy/cut/paste magic if you are in the command line
         var stopAction = function(e) {
             return e.target.id == "command";
         };
         var editorHasFocus = function() { 
-            return true;
+            return editor.focus;
         };
         
         var focuser = this.focuser = bespin.editor.clipboard.createHiddenTextarea();
         var onfocuser = false;
         
         // Copy
         this.beforecopyHandle = dojo.connect(document.body, "onbeforecopy", function(e) {
             if ((!editorHasFocus() && !onfocuser) || stopAction(e)) return;
@@ -111,17 +111,17 @@ dojo.declare("bespin.editor.clipboard.DO
             focuser.focus();
             focuser.select();
             
             // and we are now on focuser
             onfocuser = true;
         });
 
         this.copyHandle = dojo.connect(document.body, "oncopy", function(e) {
-            if (!editorHasFocus() && !onFocuser) return;
+            if (!editorHasFocus() && !onfocuser) return;
             if (stopAction(e)) return;
             
             var selectionText = editor.getSelectionAsText();
             if (selectionText && selectionText != '') {
                 e.clipboardData.setData('text/plain', selectionText);
                 dojo.stopEvent(e); // need a full stop, otherwise someone else will try to set copy data.
             }
 
@@ -139,17 +139,17 @@ dojo.declare("bespin.editor.clipboard.DO
             focuser.focus();
             focuser.select();
             
             // and we are now on focuser
             onfocuser = true;
         });
 
         this.cutHandle = dojo.connect(document, "cut", function(e) {
-            if (!editorHasFocus() && !onFocuser) return;
+            if (!editorHasFocus() && !onfocuser) return;
             if (stopAction(e)) return;
 
             var selectionObject = editor.getSelection();
 
             if (selectionObject) {
                 var selectionText = editor.model.getChunk(selectionObject);
 
                 if (selectionText && selectionText != '') {