From 22d442732064b55f05df969ff9d96b7299225070 Mon Sep 17 00:00:00 2001 From: nightwing Date: Sat, 5 May 2012 15:36:45 +0400 Subject: [PATCH] fix cut/copy on opera --- install.js | 1 - lib/ace/keyboard/textinput.js | 19 +++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/install.js b/install.js index 3db88154..f7f29ad6 100644 --- a/install.js +++ b/install.js @@ -57,7 +57,6 @@ try { compat: true, name: "ace" }); - process.exit(0); } catch (e) { console.log("--- Ace Build error ---"); console.log(e); diff --git a/lib/ace/keyboard/textinput.js b/lib/ace/keyboard/textinput.js index fa570e66..e053e33f 100644 --- a/lib/ace/keyboard/textinput.js +++ b/lib/ace/keyboard/textinput.js @@ -215,6 +215,22 @@ var TextInput = function(parentNode, host) { } }); } + else if (useragent.isOpera) { + event.addListener(parentNode, "keydown", function(e) { + if ((useragent.isMac && !e.metaKey) || !e.ctrlKey) + return; + + if ((e.keyCode == 88 || e.keyCode == 67)) { + var copyText = host.getCopyText(); + if (copyText) { + text.value = copyText; + text.select(); + if (e.keyCode == 88) + host.onCut(); + } + } + }); + } else { event.addListener(text, "copy", onCopy); event.addListener(text, "cut", onCut); @@ -264,8 +280,7 @@ var TextInput = function(parentNode, host) { text.style.cssText = 'position:fixed; z-index:1000;' + - 'left:' + (mousePos.x - 2) + 'px; top:' + (mousePos.y - 2) + 'px;'; - + 'left:' + (mousePos.x - 2) + 'px; top:' + (mousePos.y - 2) + 'px;'; } if (isEmpty) text.value='';