From 4803f92145147b37fbc5fbd7a8fcc766bbbbc945 Mon Sep 17 00:00:00 2001 From: Irakli Gozalishvili Date: Thu, 30 Jun 2011 13:53:10 +0200 Subject: [PATCH] Fix for greedy focus issue #320 --- lib/ace/keyboard/textinput.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/ace/keyboard/textinput.js b/lib/ace/keyboard/textinput.js index 2ecb1b6e..3e75d439 100644 --- a/lib/ace/keyboard/textinput.js +++ b/lib/ace/keyboard/textinput.js @@ -65,6 +65,10 @@ var TextInput = function(parentNode, host) { host.onTextInput(value); } else host.onTextInput(value); + + // If editor is no longer focused we quit immediately, since + // it means that something else like CLI is in charge now. + if (!isFocused()) return false; } } copied = false; @@ -215,6 +219,11 @@ var TextInput = function(parentNode, host) { text.blur(); }; + function isFocused() { + return document.activeElement === text; + }; + this.isFocused = isFocused; + this.getElement = function() { return text; };