You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by vn...@apache.org on 2018/01/16 18:41:52 UTC
[06/23] guacamole-client git commit: GUACAMOLE-352: Handle "input" /
"compositionend" events in a mutually-exclusive manner, as they may conflict.
GUACAMOLE-352: Handle "input" / "compositionend" events in a mutually-exclusive manner, as they may conflict.
Project: http://git-wip-us.apache.org/repos/asf/guacamole-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/guacamole-client/commit/cdacd570
Tree: http://git-wip-us.apache.org/repos/asf/guacamole-client/tree/cdacd570
Diff: http://git-wip-us.apache.org/repos/asf/guacamole-client/diff/cdacd570
Branch: refs/heads/master
Commit: cdacd570992ed57bd8b01eea3438473e3ddf0e6a
Parents: 3ee73d8
Author: Michael Jumper <mj...@apache.org>
Authored: Sun Dec 17 21:17:46 2017 -0800
Committer: Michael Jumper <mj...@apache.org>
Committed: Tue Jan 16 09:50:54 2018 -0800
----------------------------------------------------------------------
.../src/main/webapp/modules/Keyboard.js | 41 ++++++++++++++++----
1 file changed, 33 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/cdacd570/guacamole-common-js/src/main/webapp/modules/Keyboard.js
----------------------------------------------------------------------
diff --git a/guacamole-common-js/src/main/webapp/modules/Keyboard.js b/guacamole-common-js/src/main/webapp/modules/Keyboard.js
index 42020c7..e16d48e 100644
--- a/guacamole-common-js/src/main/webapp/modules/Keyboard.js
+++ b/guacamole-common-js/src/main/webapp/modules/Keyboard.js
@@ -1207,29 +1207,54 @@ Guacamole.Keyboard = function(element) {
}, true);
- // Automatically type text entered into the wrapped element
- element.addEventListener("input", function(e) {
+ /**
+ * Handles the given "input" event, typing the data within the input text.
+ * If the event is complete (text is provided), handling of "compositionend"
+ * events is suspended, as such events may conflict with input events.
+ *
+ * @private
+ * @param {InputEvent} e
+ * The "input" event to handle.
+ */
+ var handleInput = function handleInput(e) {
// Only intercept if handler set
if (!guac_keyboard.onkeydown && !guac_keyboard.onkeyup) return;
// Type all content written
- if (e.data)
+ if (e.data) {
+ element.removeEventListener("compositionend", handleComposition, false);
guac_keyboard.type(e.data);
+ }
- }, false);
+ };
- // Automatically type the result of composed characters/text
- element.addEventListener("compositionend", function(e) {
+ /**
+ * Handles the given "compositionend" event, typing the data within the
+ * composed text. If the event is complete (composed text is provided),
+ * handling of "input" events is suspended, as such events may conflict
+ * with composition events.
+ *
+ * @private
+ * @param {CompositionEvent} e
+ * The "compositionend" event to handle.
+ */
+ var handleComposition = function handleComposition(e) {
// Only intercept if handler set
if (!guac_keyboard.onkeydown && !guac_keyboard.onkeyup) return;
// Type all content written
- if (e.data)
+ if (e.data) {
+ element.removeEventListener("input", handleInput, false);
guac_keyboard.type(e.data);
+ }
- }, false);
+ };
+
+ // Automatically type text entered into the wrapped element
+ element.addEventListener("input", handleInput, false);
+ element.addEventListener("compositionend", handleComposition, false);
};