You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2010/07/20 09:14:43 UTC

svn commit: r965739 - /myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js

Author: lofwyr
Date: Tue Jul 20 07:14:43 2010
New Revision: 965739

URL: http://svn.apache.org/viewvc?rev=965739&view=rev
Log:
TOBAGO-899: Posibility to select text inside of the sheet

Modified:
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js?rev=965739&r1=965738&r2=965739&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js Tue Jul 20 07:14:43 2010
@@ -431,6 +431,7 @@ Tobago.Sheet.prototype.addSelectionListe
   var currentSheet = this;
   currentSheet.getRows().each(function() {
     var row = this;
+    Tobago.addBindEventListener(row, "mousedown", currentSheet, "doMouseDownSelect");
     Tobago.addBindEventListener(row, "click", currentSheet, "doSelection");
     if (this.dblClickActionId) {
       Tobago.addBindEventListener(row, "dblclick", currentSheet, "doDblClick");
@@ -438,6 +439,14 @@ Tobago.Sheet.prototype.addSelectionListe
   });
 };
 
+Tobago.Sheet.prototype.doMouseDownSelect = function(event) {
+  if (!event) {
+    event = window.event;
+  }
+  this.mouseDownX = event.clientX;
+  this.mouseDownY = event.clientY;
+};
+
 Tobago.Sheet.prototype.doSelection = function(event) {
     if (! event) {
       event = window.event;
@@ -459,6 +468,12 @@ Tobago.Sheet.prototype.doSelection = fun
     //LOG.debug("ID " + this.id);
     if (! Tobago.isInputElement(srcElement.tagName)) {
 
+      if (Math.abs(this.mouseDownX - event.clientX) + Math.abs(this.mouseDownY - event.clientY) > 5) {
+        // The user has moved the mouse. We assume, the user want to select some text inside the sheet,
+        // so we doesn't select the row.
+        return;
+      }
+      
       Tobago.clearSelection();
 
       // find the row, if the has clicked on an element inside the row