textinput fixes for IE

This commit is contained in:
Fabian Jakobs 2011-08-16 11:48:40 +02:00
commit 573f532a07
2 changed files with 15 additions and 12 deletions

View file

@ -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();
};

View file

@ -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();
};