mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 03:44:02 +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 MAX_WARNINGS = 3;
|
||||
var numWarnings = 0;
|
||||
var isKeyboardRaised = false;
|
||||
|
||||
function shouldRaiseKeyboard() {
|
||||
if (document.activeElement.nodeName == "INPUT" || document.activeElement.nodeName == "TEXTAREA") {
|
||||
|
@ -28,13 +29,15 @@
|
|||
};
|
||||
|
||||
setInterval(function () {
|
||||
var event = shouldRaiseKeyboard() ? "_RAISE_KEYBOARD" : "_LOWER_KEYBOARD";
|
||||
if (typeof EventBridge != "undefined") {
|
||||
EventBridge.emitWebEvent(event);
|
||||
} else {
|
||||
if (numWarnings < MAX_WARNINGS) {
|
||||
console.log("WARNING: no global EventBridge object found");
|
||||
numWarnings++;
|
||||
if (isKeyboardRaised !== shouldRaiseKeyboard()) {
|
||||
isKeyboardRaised = !isKeyboardRaised;
|
||||
if (typeof EventBridge != "undefined") {
|
||||
EventBridge.emitWebEvent(isKeyboardRaised ? "_RAISE_KEYBOARD" : "_LOWER_KEYBOARD");
|
||||
} else {
|
||||
if (numWarnings < MAX_WARNINGS) {
|
||||
console.log("WARNING: no global EventBridge object found");
|
||||
numWarnings++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}, POLL_FREQUENCY);
|
||||
|
|
Loading…
Reference in a new issue