From: Wilmer Ricciotti Date: Wed, 13 Jul 2011 15:49:47 +0000 (+0000) Subject: more tests on keyboard handling. X-Git-Tag: make_still_working~2379 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=f021bc3803ea15dc8f87d09604eb5911421a6281;p=helm.git more tests on keyboard handling. --- diff --git a/matitaB/matita/matitaweb.js b/matitaB/matita/matitaweb.js index e67594429..38f8c97d0 100644 --- a/matitaB/matita/matitaweb.js +++ b/matitaB/matita/matitaweb.js @@ -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 */