mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-07 13:41:21 +00:00
GUAC-692: Clean grouping of text input elements.
This commit is contained in:
@@ -205,9 +205,19 @@ GuacUI.Client = {
|
|||||||
"main" : document.getElementById("main"),
|
"main" : document.getElementById("main"),
|
||||||
"display" : document.getElementById("display"),
|
"display" : document.getElementById("display"),
|
||||||
"notification_area" : document.getElementById("notificationArea"),
|
"notification_area" : document.getElementById("notificationArea"),
|
||||||
"target" : document.getElementById("target"),
|
|
||||||
"text_input" : document.getElementById("text-input"),
|
/* Text input */
|
||||||
"sent_history" : document.getElementById("sent-history"),
|
|
||||||
|
"text_input" : {
|
||||||
|
"container" : document.getElementById("text-input"),
|
||||||
|
"sent" : document.getElementById("sent-history"),
|
||||||
|
"target" : document.getElementById("target"),
|
||||||
|
"ctrl" : document.getElementById("text-ctrl"),
|
||||||
|
"alt" : document.getElementById("text-alt"),
|
||||||
|
"esc" : document.getElementById("text-esc"),
|
||||||
|
"tab" : document.getElementById("text-tab"),
|
||||||
|
"enabled" : false
|
||||||
|
},
|
||||||
|
|
||||||
/* Menu */
|
/* Menu */
|
||||||
|
|
||||||
@@ -245,10 +255,6 @@ GuacUI.Client = {
|
|||||||
"touch_screen" : null,
|
"touch_screen" : null,
|
||||||
"touch_pad" : null,
|
"touch_pad" : null,
|
||||||
|
|
||||||
/* Text input */
|
|
||||||
|
|
||||||
"ime_enabled" : false,
|
|
||||||
|
|
||||||
/* Clipboard */
|
/* Clipboard */
|
||||||
|
|
||||||
"remote_clipboard" : "",
|
"remote_clipboard" : "",
|
||||||
@@ -869,12 +875,12 @@ GuacUI.Client.showMenu = function(shown) {
|
|||||||
*/
|
*/
|
||||||
GuacUI.Client.showTextInput = function(shown) {
|
GuacUI.Client.showTextInput = function(shown) {
|
||||||
if (shown === false) {
|
if (shown === false) {
|
||||||
GuacUI.Client.text_input.className = "closed";
|
GuacUI.Client.text_input.container.className = "closed";
|
||||||
GuacUI.Client.target.blur();
|
GuacUI.Client.text_input.target.blur();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
GuacUI.Client.text_input.className = "open";
|
GuacUI.Client.text_input.container.className = "open";
|
||||||
GuacUI.Client.target.focus();
|
GuacUI.Client.text_input.target.focus();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1428,7 +1434,7 @@ GuacUI.Client.attach = function(guac) {
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Allow all but specific keys through to browser when in IME mode
|
// Allow all but specific keys through to browser when in IME mode
|
||||||
if (GuacUI.Client.ime_enabled && !IME_ALLOWED_KEYS[keysym])
|
if (GuacUI.Client.text_input.enabled && !IME_ALLOWED_KEYS[keysym])
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
GuacUI.Client.attachedClient.sendKeyEvent(pressed, keysym);
|
GuacUI.Client.attachedClient.sendKeyEvent(pressed, keysym);
|
||||||
@@ -1898,7 +1904,7 @@ GuacUI.Client.attach = function(guac) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Disable automatic capitalization on platforms that support this attribute
|
// Disable automatic capitalization on platforms that support this attribute
|
||||||
GuacUI.Client.target.setAttribute("autocapitalize", "off");
|
GuacUI.Client.text_input.target.setAttribute("autocapitalize", "off");
|
||||||
|
|
||||||
function keysym_from_codepoint(codepoint) {
|
function keysym_from_codepoint(codepoint) {
|
||||||
|
|
||||||
@@ -1973,7 +1979,7 @@ GuacUI.Client.attach = function(guac) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Display the text that was sent
|
// Display the text that was sent
|
||||||
var notify_sent = GuacUI.createChildElement(GuacUI.Client.sent_history, "div", "sent-text");
|
var notify_sent = GuacUI.createChildElement(GuacUI.Client.text_input.sent, "div", "sent-text");
|
||||||
notify_sent.textContent = sent_text;
|
notify_sent.textContent = sent_text;
|
||||||
|
|
||||||
// Remove text after one second
|
// Remove text after one second
|
||||||
@@ -1983,46 +1989,46 @@ GuacUI.Client.attach = function(guac) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GuacUI.Client.target.onfocus = function() {
|
GuacUI.Client.text_input.target.onfocus = function() {
|
||||||
|
|
||||||
GuacUI.Client.ime_enabled = true;
|
GuacUI.Client.text_input.enabled = true;
|
||||||
|
|
||||||
// Reset content
|
// Reset content
|
||||||
GuacUI.Client.target.value = new Array(257).join("\u200B");
|
GuacUI.Client.text_input.target.value = new Array(257).join("\u200B");
|
||||||
GuacUI.Client.target.setSelectionRange(128, 128);
|
GuacUI.Client.text_input.target.setSelectionRange(128, 128);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GuacUI.Client.target.onblur = function() {
|
GuacUI.Client.text_input.target.onblur = function() {
|
||||||
GuacUI.Client.ime_enabled = false;
|
GuacUI.Client.text_input.enabled = false;
|
||||||
GuacUI.Client.target.focus();
|
GuacUI.Client.text_input.target.focus();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Track state of composition
|
// Track state of composition
|
||||||
var composing_text = false;
|
var composing_text = false;
|
||||||
|
|
||||||
GuacUI.Client.target.addEventListener("compositionstart", function(e) {
|
GuacUI.Client.text_input.target.addEventListener("compositionstart", function(e) {
|
||||||
composing_text = true;
|
composing_text = true;
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
GuacUI.Client.target.addEventListener("compositionend", function(e) {
|
GuacUI.Client.text_input.target.addEventListener("compositionend", function(e) {
|
||||||
composing_text = false;
|
composing_text = false;
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
GuacUI.Client.target.addEventListener("input", function(e) {
|
GuacUI.Client.text_input.target.addEventListener("input", function(e) {
|
||||||
|
|
||||||
// Ignore input events during text composition
|
// Ignore input events during text composition
|
||||||
if (composing_text)
|
if (composing_text)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var i;
|
var i;
|
||||||
var content = GuacUI.Client.target.value;
|
var content = GuacUI.Client.text_input.target.value;
|
||||||
|
|
||||||
// If content removed, update
|
// If content removed, update
|
||||||
if (content.length < 256) {
|
if (content.length < 256) {
|
||||||
|
|
||||||
// Calculate number of backspaces and send
|
// Calculate number of backspaces and send
|
||||||
var backspace_count = 128 - GuacUI.Client.target.selectionStart;
|
var backspace_count = 128 - GuacUI.Client.text_input.target.selectionStart;
|
||||||
for (i=0; i<backspace_count; i++)
|
for (i=0; i<backspace_count; i++)
|
||||||
send_keysym(0xFF08);
|
send_keysym(0xFF08);
|
||||||
|
|
||||||
@@ -2037,8 +2043,8 @@ GuacUI.Client.attach = function(guac) {
|
|||||||
send_string(content);
|
send_string(content);
|
||||||
|
|
||||||
// Reset content
|
// Reset content
|
||||||
GuacUI.Client.target.value = new Array(257).join("\u200B");
|
GuacUI.Client.text_input.target.value = new Array(257).join("\u200B");
|
||||||
GuacUI.Client.target.setSelectionRange(128, 128);
|
GuacUI.Client.text_input.target.setSelectionRange(128, 128);
|
||||||
|
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user