Raise and lower keyboard in entities editor

This commit is contained in:
David Rowe 2016-09-28 17:57:53 +13:00
parent 2344d15dbc
commit a94d77ee12
7 changed files with 50 additions and 0 deletions

View file

@ -14,6 +14,7 @@
<script type="text/javascript" src="qrc:///qtwebchannel/qwebchannel.js"></script>
<script type="text/javascript" src="js/eventBridgeLoader.js"></script>
<script type="text/javascript" src="js/spinButtons.js"></script>
<script type="text/javascript" src="js/keyboardControl.js"></script>
<script type="text/javascript" src="js/entityList.js"></script>
</head>
<body onload='loaded();'>

View file

@ -19,6 +19,7 @@
<script type="text/javascript" src="qrc:///qtwebchannel/qwebchannel.js"></script>
<script type="text/javascript" src="js/eventBridgeLoader.js"></script>
<script type="text/javascript" src="js/spinButtons.js"></script>
<script type="text/javascript" src="js/keyboardControl.js"></script>
<script type="text/javascript" src="js/entityProperties.js"></script>
<script src="js/jsoneditor.min.js"></script>
</head>

View file

@ -16,6 +16,7 @@
<script type="text/javascript" src="qrc:///qtwebchannel/qwebchannel.js"></script>
<script type="text/javascript" src="js/eventBridgeLoader.js"></script>
<script type="text/javascript" src="js/spinButtons.js"></script>
<script type="text/javascript" src="js/keyboardControl.js"></script>
<script type="text/javascript" src="js/gridControls.js"></script>
</head>
<body onload='loaded();'>

View file

@ -412,6 +412,8 @@ function loaded() {
augmentSpinButtons();
setUpKeyboardControl();
// Disable right-click context menu which is not visible in the HMD and makes it seem like the app has locked
document.addEventListener("contextmenu", function (event) {
event.preventDefault();

View file

@ -1590,6 +1590,8 @@ function loaded() {
augmentSpinButtons();
setUpKeyboardControl();
// Disable right-click context menu which is not visible in the HMD and makes it seem like the app has locked
document.addEventListener("contextmenu", function(event) {
event.preventDefault();

View file

@ -127,6 +127,8 @@ function loaded() {
augmentSpinButtons();
setUpKeyboardControl();
EventBridge.emitWebEvent(JSON.stringify({ type: 'init' }));
});

View file

@ -0,0 +1,41 @@
//
// keyboardControl.js
//
// Created by David Rowe on 28 Sep 2016.
// Copyright 2016 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
function setUpKeyboardControl() {
var lowerTimer = null;
function raiseKeyboard() {
if (lowerTimer !== null) {
clearTimeout(lowerTimer);
lowerTimer = null;
}
EventBridge.emitWebEvent("_RAISE_KEYBOARD");
}
function doLowerKeyboard() {
EventBridge.emitWebEvent("_LOWER_KEYBOARD");
lowerTimer = null;
}
function lowerKeyboard() {
// Delay lowering keyboard a little in case immediately raise it again.
if (lowerTimer === null) {
lowerTimer = setTimeout(doLowerKeyboard, 20);
}
}
var inputs = document.querySelectorAll("input[type=text], input[type=number], textarea");
for (var i = 0, length = inputs.length; i < length; i++) {
inputs[i].addEventListener("focus", raiseKeyboard);
inputs[i].addEventListener("blur", lowerKeyboard);
}
}