do not store clipboard state in textinput

This commit is contained in:
nightwing 2012-04-26 19:45:18 +04:00
commit fcb172f665

View file

@ -61,7 +61,6 @@ var TextInput = function(parentNode, host) {
var copied = false;
var pasted = false;
var tempStyle = '';
var outsideCopyText = "";
function select() {
try {
@ -135,12 +134,9 @@ var TextInput = function(parentNode, host) {
var onCopy = function(e) {
copied = true;
outsideCopyText = "";
var copyText = host.getCopyText();
if(copyText) {
if(copyText)
text.value = copyText;
host.onCopy();
}
else
e.preventDefault();
select();
@ -151,7 +147,6 @@ var TextInput = function(parentNode, host) {
var onCut = function(e) {
copied = true;
outsideCopyText = "";
var copyText = host.getCopyText();
if(copyText) {
text.value = copyText;
@ -164,22 +159,6 @@ var TextInput = function(parentNode, host) {
}, 0);
};
// these emit methods can be used for outside of the keyboard command context
this.emitCut = function() {
onCut();
outsideCopyText = text.value;
}
this.emitCopy = function() {
onCopy();
outsideCopyText = text.value;
}
this.emitPaste = function() {
pasted = true;
sendText(outsideCopyText);
}
event.addCommandKeyListener(text, host.onCommandKey.bind(host));
if (useragent.isOldIE) {
@ -205,10 +184,7 @@ var TextInput = function(parentNode, host) {
// Some browsers support the event.clipboardData API. Use this to get
// the pasted content which increases speed if pasting a lot of lines.
if (e.clipboardData && e.clipboardData.getData) {
if (outsideCopyText.length > 0)
sendText(outsideCopyText);
else
sendText(e.clipboardData.getData("text/plain"));
sendText(e.clipboardData.getData("text/plain"));
e.preventDefault();
}
else {