mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-07 13:41:21 +00:00
Automatically reset text area on keyboard events if native OSK is enabled/assumed. Hide text area via CSS.
This commit is contained in:
@@ -54,10 +54,8 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<input id="eventTarget"
|
<!-- Keyboard event target for platforms with native OSKs -->
|
||||||
type="text"
|
<textarea id="eventTarget">GUAC</textarea>
|
||||||
style="width: 0; height: 0; position: fixed; opacity: 0"
|
|
||||||
value="x"/>
|
|
||||||
|
|
||||||
<!-- Display -->
|
<!-- Display -->
|
||||||
<div id="display">
|
<div id="display">
|
||||||
|
@@ -178,7 +178,8 @@ var GuacamoleUI = {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var assumeNativeOSK = false;
|
// Assume no native OSK by default
|
||||||
|
GuacamoleUI.assumeNativeOSK = false;
|
||||||
|
|
||||||
// Show/Hide keyboard
|
// Show/Hide keyboard
|
||||||
var keyboardResizeInterval = null;
|
var keyboardResizeInterval = null;
|
||||||
@@ -186,7 +187,7 @@ var GuacamoleUI = {
|
|||||||
|
|
||||||
// If we think the platform has a native OSK, use the event target to
|
// If we think the platform has a native OSK, use the event target to
|
||||||
// cause it to display.
|
// cause it to display.
|
||||||
if (assumeNativeOSK) {
|
if (GuacamoleUI.assumeNativeOSK) {
|
||||||
GuacamoleUI.eventTarget.focus();
|
GuacamoleUI.eventTarget.focus();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -294,7 +295,7 @@ var GuacamoleUI = {
|
|||||||
menuShowLongPressTimeout = null;
|
menuShowLongPressTimeout = null;
|
||||||
|
|
||||||
// Assume native OSK if menu shown via long-press
|
// Assume native OSK if menu shown via long-press
|
||||||
assumeNativeOSK = true;
|
GuacamoleUI.assumeNativeOSK = true;
|
||||||
GuacamoleUI.showMenu();
|
GuacamoleUI.showMenu();
|
||||||
|
|
||||||
}, 800);
|
}, 800);
|
||||||
@@ -307,9 +308,11 @@ var GuacamoleUI = {
|
|||||||
menuShowLongPressTimeout = null;
|
menuShowLongPressTimeout = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Ensure the event target ALWAYS has text inside.
|
// Reset event target (add content, reposition cursor in middle.
|
||||||
GuacamoleUI.eventTarget.onchange = function() {
|
GuacamoleUI.resetEventTarget = function() {
|
||||||
GuacamoleUI.eventTarget.value = "x";
|
GuacamoleUI.eventTarget.value = "GUAC";
|
||||||
|
GuacamoleUI.eventTarget.selectionStart =
|
||||||
|
GuacamoleUI.eventTarget.selectionEnd = 2;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Detect long-press at bottom of screen
|
// Detect long-press at bottom of screen
|
||||||
@@ -405,6 +408,12 @@ GuacamoleUI.attach = function(guac) {
|
|||||||
function enableKeyboard() {
|
function enableKeyboard() {
|
||||||
keyboard.onkeydown =
|
keyboard.onkeydown =
|
||||||
function (keysym) {
|
function (keysym) {
|
||||||
|
|
||||||
|
// If we're using native OSK, ensure event target is reset
|
||||||
|
// on each key event.
|
||||||
|
if (GuacamoleUI.assumeNativeOSK)
|
||||||
|
GuacamoleUI.resetEventTarget();
|
||||||
|
|
||||||
guac.sendKeyEvent(1, keysym);
|
guac.sendKeyEvent(1, keysym);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -211,3 +211,10 @@ div#viewportClone {
|
|||||||
|
|
||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
textarea#eventTarget {
|
||||||
|
position: fixed;
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
opacity: 0;
|
||||||
|
}
|
Reference in New Issue
Block a user