mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 04:24:47 +02:00
Don't flood event bridge with raise/lower keyboard messages from HTML
This commit is contained in:
parent
bc8c400448
commit
ec00129988
1 changed files with 10 additions and 7 deletions
|
@ -11,6 +11,7 @@
|
||||||
var POLL_FREQUENCY = 500; // ms
|
var POLL_FREQUENCY = 500; // ms
|
||||||
var MAX_WARNINGS = 3;
|
var MAX_WARNINGS = 3;
|
||||||
var numWarnings = 0;
|
var numWarnings = 0;
|
||||||
|
var isKeyboardRaised = false;
|
||||||
|
|
||||||
function shouldRaiseKeyboard() {
|
function shouldRaiseKeyboard() {
|
||||||
if (document.activeElement.nodeName == "INPUT" || document.activeElement.nodeName == "TEXTAREA") {
|
if (document.activeElement.nodeName == "INPUT" || document.activeElement.nodeName == "TEXTAREA") {
|
||||||
|
@ -28,13 +29,15 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
setInterval(function () {
|
setInterval(function () {
|
||||||
var event = shouldRaiseKeyboard() ? "_RAISE_KEYBOARD" : "_LOWER_KEYBOARD";
|
if (isKeyboardRaised !== shouldRaiseKeyboard()) {
|
||||||
if (typeof EventBridge != "undefined") {
|
isKeyboardRaised = !isKeyboardRaised;
|
||||||
EventBridge.emitWebEvent(event);
|
if (typeof EventBridge != "undefined") {
|
||||||
} else {
|
EventBridge.emitWebEvent(isKeyboardRaised ? "_RAISE_KEYBOARD" : "_LOWER_KEYBOARD");
|
||||||
if (numWarnings < MAX_WARNINGS) {
|
} else {
|
||||||
console.log("WARNING: no global EventBridge object found");
|
if (numWarnings < MAX_WARNINGS) {
|
||||||
numWarnings++;
|
console.log("WARNING: no global EventBridge object found");
|
||||||
|
numWarnings++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, POLL_FREQUENCY);
|
}, POLL_FREQUENCY);
|
||||||
|
|
Loading…
Reference in a new issue