diff --git a/lib/file-control.php b/lib/file-control.php index ae604fb..f4a460b 100644 --- a/lib/file-control.php +++ b/lib/file-control.php @@ -352,7 +352,7 @@ if (action=="load") { cM.setValue(document.getElementById('loadedFile').value); top.document.getElementById('content').style.visibility='visible'; top.ICEcoder.switchTab(top.ICEcoder.selectedTab); - cM.focus(); + top.ICEcoder.focus(); // Then clean it up, set the text cursor, update the display and get the character data top.ICEcoder.contentCleanUp(); diff --git a/lib/ice-coder.js b/lib/ice-coder.js index 709e432..9765b94 100644 --- a/lib/ice-coder.js +++ b/lib/ice-coder.js @@ -216,13 +216,23 @@ var ICEcoder = { cM.setSelection({line:line,ch:0}, {line:line,ch:cM.lineInfo(line).text.length}); }, + // Focus the editor + focus: function(line) { + var cM; + + if (!(/iPhone|iPad|iPod/i.test(navigator.userAgent))) { + cM = top.ICEcoder.getcMInstance(); + cM.focus(); + } + }, + // Go to a specific line number goToLine: function(lineNo) { var cM; cM = ICEcoder.getcMInstance(); cM.setCursor(lineNo ? lineNo-1 : top.get('goToLineNo').value-1); - cM.focus(); + top.ICEcoder.focus(); return false; }, @@ -367,7 +377,7 @@ var ICEcoder = { // Set our ch position just after the tag, and refocus on the editor ch = cM.getLine(line).indexOf(">",cM.getLine(line).indexOf("<"+tag))+1; cM.setCursor(line,ch); - cM.focus(); + top.ICEcoder.focus(); // Now update nest display to this nest depth & without any HTML tags to kill further interactivity chPos = 0; for (var i=0;i<=nestPos;i++) { @@ -1102,7 +1112,7 @@ var ICEcoder = { } // Finally, highlight our selection cM.setSelection(cursor.from(), cursor.to()); - cM.focus(); + top.ICEcoder.focus(); top.ICEcoder.findMode = true; } return true; @@ -1514,7 +1524,7 @@ var ICEcoder = { cM = ICEcoder.getcMInstance(); top.ICEcoder.codeAssist = !top.ICEcoder.codeAssist; top.ICEcoder.cssColorPreview(); - cM.focus(); + top.ICEcoder.focus(); for (i=0;i-1) { @@ -1787,7 +1797,7 @@ var ICEcoder = { cM.getWrapperElement().style.display = "block"; // Focus on & refresh our selected instance - if (!noFocus) {setTimeout(function() {cM.focus();},4);} + if (!noFocus) {setTimeout(function() {top.ICEcoder.focus();},4);} cM.refresh(); // Highlight the selected tab @@ -2303,7 +2313,7 @@ var ICEcoder = { // Space outisde of editor (Focus on editor) } else if(key==32 && area!="content" && ["find","replace"].indexOf(document.activeElement.id)==-1) { if (top.ICEcoder.getcMInstance()) { - top.ICEcoder.getcMInstance().focus(); + top.ICEcoder.focus(); } return false; @@ -2401,7 +2411,7 @@ var ICEcoder = { cM.setLine(lineNo, replacedLine.replace("CURSOR","")); cM.setCursor(lineNoCount,curPos); // Finally, focus on the editor - cM.focus(); + top.ICEcoder.focus(); } } }; \ No newline at end of file