From 011e5636bb037a30d8d49b6f39f2ab97441d3d7e Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Fri, 23 Mar 2012 23:18:41 -0700 Subject: [PATCH] No need for constant "GUAC" or reselection. Added oninput handler such that voice input, etc. will also work! --- src/main/webapp/client.xhtml | 2 +- src/main/webapp/scripts/interface.js | 39 +++++++++++++++++++++++++++++++--- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/src/main/webapp/client.xhtml b/src/main/webapp/client.xhtml index 9213907..2ac8a7a 100644 --- a/src/main/webapp/client.xhtml +++ b/src/main/webapp/client.xhtml @@ -55,7 +55,7 @@ - +
diff --git a/src/main/webapp/scripts/interface.js b/src/main/webapp/scripts/interface.js index be79b38..4fecbc7 100644 --- a/src/main/webapp/scripts/interface.js +++ b/src/main/webapp/scripts/interface.js @@ -351,9 +351,7 @@ var GuacamoleUI = { // Reset event target (add content, reposition cursor in middle. GuacamoleUI.resetEventTarget = function() { - GuacamoleUI.eventTarget.value = "GUAC"; - GuacamoleUI.eventTarget.selectionStart = - GuacamoleUI.eventTarget.selectionEnd = 2; + GuacamoleUI.eventTarget.value = ""; }; // Detect long-press at bottom of screen @@ -600,6 +598,41 @@ GuacamoleUI.attach = function(guac) { guac.disconnect(); }; + // If text is input directly into event target without typing (as with + // voice input, for example), type automatically. + GuacamoleUI.eventTarget.oninput = function(e) { + + // Get input text + var text = GuacamoleUI.eventTarget.value; + + // Send each character + for (var i=0; i= 0x0000 && charCode <= 0x00FF) + keysym = charCode; + else if (charCode >= 0x0100 && charCode <= 0x10FFFF) + keysym = 0x01000000 | charCode; + + // Press and release key + guac.sendKeyEvent(1, keysym); + guac.sendKeyEvent(0, keysym); + + } + + // Reset target + GuacamoleUI.resetEventTarget(); + + // Stop event + e.preventDefault(); + return false; + + } + // Handle clipboard events GuacamoleUI.clipboard.onchange = function() { -- 1.7.10.4