From ddccaa75b2b186612540a1d5399ef92abed21fc9 Mon Sep 17 00:00:00 2001 From: Fabian Jakobs Date: Sat, 12 Feb 2011 15:02:55 +0100 Subject: [PATCH] fix copy, cut and past in IE --- lib/ace/keyboard/textinput.js | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/lib/ace/keyboard/textinput.js b/lib/ace/keyboard/textinput.js index 743829f3..cda0aab2 100644 --- a/lib/ace/keyboard/textinput.js +++ b/lib/ace/keyboard/textinput.js @@ -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) {