From: Michael Jumper Date: Sat, 24 Mar 2012 06:18:41 +0000 (-0700) Subject: No need for constant "GUAC" or reselection. Added oninput handler such that voice... X-Git-Url: http://git.alex.org.uk No need for constant "GUAC" or reselection. Added oninput handler such that voice input, etc. will also work! --- 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() {