diff --git a/lib/ace/editor.js b/lib/ace/editor.js index f0e0c972..af3ec259 100644 --- a/lib/ace/editor.js +++ b/lib/ace/editor.js @@ -263,13 +263,10 @@ var Editor =function(renderer, session) { // Safari needs the timeout // iOS and Firefox need it called immediately // to be on the save side we do both - // except for IE var _self = this; - if (!useragent.isIE) { - setTimeout(function() { - _self.textInput.focus(); - }); - } + setTimeout(function() { + _self.textInput.focus(); + }); this.textInput.focus(); }; diff --git a/lib/ace/keyboard/textinput.js b/lib/ace/keyboard/textinput.js index 744fe4e5..268af0f3 100644 --- a/lib/ace/keyboard/textinput.js +++ b/lib/ace/keyboard/textinput.js @@ -57,6 +57,12 @@ var TextInput = function(parentNode, host) { var pasted = false; var tempStyle = ''; + function select() { + try { + text.select(); + } catch (e) {} + }; + function sendText(valueToSend) { if (!copied) { var value = valueToSend || text.value; @@ -82,7 +88,7 @@ var TextInput = function(parentNode, host) { // Safari doesn't fire copy events if no text is selected text.value = PLACEHOLDER; - text.select(); + select(); } var onTextInput = function(e) { @@ -123,12 +129,12 @@ var TextInput = function(parentNode, host) { text.value = copyText; else e.preventDefault(); - text.select(); + select(); setTimeout(function () { sendText(); }, 0); }; - + var onCut = function(e) { copied = true; var copyText = host.getCopyText(); @@ -137,7 +143,7 @@ var TextInput = function(parentNode, host) { host.onCut(); } else e.preventDefault(); - text.select(); + select(); setTimeout(function () { sendText(); }, 0); @@ -216,12 +222,12 @@ var TextInput = function(parentNode, host) { event.addListener(text, "focus", function() { host.onFocus(); - text.select(); + select(); }); this.focus = function() { host.onFocus(); - text.select(); + select(); text.focus(); };