"menuControl" : document.getElementById("menuControl"),
"touchMenu" : document.getElementById("touchMenu"),
"logo" : document.getElementById("status-logo"),
+ "eventTarget" : document.getElementById("eventTarget"),
"buttons": {
};
+ // Assume no native OSK by default
+ GuacamoleUI.nativeOSK = false;
+
// Show/Hide keyboard
var keyboardResizeInterval = null;
GuacamoleUI.buttons.showKeyboard.onclick = function() {
+ // If we think the platform has a native OSK, use the event target to
+ // cause it to display.
+ if (GuacamoleUI.nativeOSK) {
+ GuacamoleUI.eventTarget.focus();
+ return;
+ }
+
var displayed = GuacamoleUI.containers.keyboard.style.display;
if (displayed != "block") {
GuacamoleUI.containers.keyboard.style.display = "block";
// Wait and then show menu
detectMenuOpenTimeout = window.setTimeout(function() {
+
+ // If menu opened via mouse, do not show native OSK
+ GuacamoleUI.nativeOSK = false;
+
GuacamoleUI.showMenu();
detectMenuOpenTimeout = null;
}, 325);
};
// Initiate detection of menu close action. If not canceled through some
- // user event, menu will close.
+ // user mouse event, menu will close.
GuacamoleUI.startMenuCloseDetect = function() {
if (!detectMenuCloseTimeout) {
menuShowLongPressTimeout = window.setTimeout(function() {
menuShowLongPressTimeout = null;
+
+ // Assume native OSK if menu shown via long-press
+ GuacamoleUI.nativeOSK = true;
GuacamoleUI.showMenu();
}, 800);
menuShowLongPressTimeout = null;
};
+ // Reset event target (add content, reposition cursor in middle.
+ GuacamoleUI.resetEventTarget = function() {
+ GuacamoleUI.eventTarget.value = "GUAC";
+ GuacamoleUI.eventTarget.selectionStart =
+ GuacamoleUI.eventTarget.selectionEnd = 2;
+ };
+
// Detect long-press at bottom of screen
document.body.addEventListener('touchstart', GuacamoleUI.startLongPressDetect, true);
function enableKeyboard() {
keyboard.onkeydown =
function (keysym) {
+
+ // If we're using native OSK, ensure event target is reset
+ // on each key event.
+ if (GuacamoleUI.nativeOSK)
+ GuacamoleUI.resetEventTarget();
+
guac.sendKeyEvent(1, keysym);
};