fix copy, cut and past in IE

This commit is contained in:
Fabian Jakobs 2011-02-12 15:02:55 +01:00
commit ddccaa75b2

View file

@ -114,7 +114,6 @@ var TextInput = function(parentNode, host) {
setTimeout(function () {
sendText();
}, 0);
};
var onCut = function(e) {
@ -129,7 +128,6 @@ var TextInput = function(parentNode, host) {
setTimeout(function () {
sendText();
}, 0);
};
event.addCommandKeyListener(text, host.onCommandKey.bind(host));
@ -163,8 +161,29 @@ var TextInput = function(parentNode, host) {
event.addListener(text, "propertychange", onTextInput);
};
event.addListener(text, "copy", onCopy);
event.addListener(text, "cut", onCut);
if (useragent.isIE) {
event.addListener(text, "beforecopy", function(e) {
var copyText = host.getCopyText();
if(copyText)
clipboardData.setData("Text", copyText);
else
e.preventDefault();
});
event.addListener(parentNode, "keydown", function(e) {
if (e.ctrlKey && e.keyCode == 88) {
var copyText = host.getCopyText();
if (copyText) {
clipboardData.setData("Text", copyText);
host.onCut();
}
event.preventDefault(e)
}
});
}
else {
event.addListener(text, "copy", onCopy);
event.addListener(text, "cut", onCut);
}
event.addListener(text, "compositionstart", onCompositionStart);
if (useragent.isGecko) {