]> matita.cs.unibo.it Git - helm.git/commitdiff
more tests on keyboard handling.
authorWilmer Ricciotti <ricciott@cs.unibo.it>
Wed, 13 Jul 2011 15:49:47 +0000 (15:49 +0000)
committerWilmer Ricciotti <ricciott@cs.unibo.it>
Wed, 13 Jul 2011 15:49:47 +0000 (15:49 +0000)
matitaB/matita/matitaweb.js

index e6759442942192740ee69059608864169d1b80ec..38f8c97d01bb7b4b4f24f9ba7896baec28b803de 100644 (file)
@@ -116,7 +116,11 @@ function restoreSelection() {
             var s = window.getSelection();
             if (s.rangeCount > 0) 
                 s.removeAllRanges();
-            s.addRange(savedRange);
+           range = document.createRange();
+           range.startContainer = savedsc;
+           range.startOffset = savedso;
+           range.collapse(true);
+            s.addRange(range);
         }
         else 
             if (document.createRange)//non IE and no selection
@@ -644,13 +648,16 @@ function removeElement(id) {
   element.parentNode.removeChild(element);
 } 
 
-var savedRange;
+var savedsc;
+var savedso;
 
 function getCursorPos() {
   var cursorPos;
   if (window.getSelection) {
     var selObj = window.getSelection();
     savedRange = selObj.getRangeAt(0);
+    savedsc = savedRange.startContainer;
+    savedso = savedRange.startOffset;
     //cursorPos =  findNode(selObj.anchorNode.parentNode.childNodes, selObj.anchorNode) + selObj.anchorOffset;
     cursorPos =  findNode(unlocked.childNodes, selObj.anchorNode,0) + selObj.anchorOffset;
     /* FIXME the following works wrong in Opera when the document is longer than 32767 chars */