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