mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-07 14:30:38 +02:00
hide cursor
This commit is contained in:
parent
0f6ad4eba0
commit
38d49854cb
2 changed files with 32 additions and 13 deletions
|
@ -20,7 +20,7 @@ Script.include("../../libraries/globals.js");
|
|||
Script.include("../../libraries/virtualKeyboard.js");
|
||||
|
||||
var windowDimensions = Controller.getViewportDimensions();
|
||||
var cursor = null;
|
||||
var cursor = new Cursor({visible: false});
|
||||
var keyboard = new Keyboard({visible: false});
|
||||
var textFontSize = 9;
|
||||
var text = null;
|
||||
|
@ -91,7 +91,7 @@ keyboard.onFullyLoaded = function() {
|
|||
});
|
||||
updateTextOverlay();
|
||||
// the cursor is being loaded after the keyboard, else it will be on the background of the keyboard
|
||||
cursor = new Cursor();
|
||||
cursor.updateVisibility(keyboard.visible);
|
||||
cursor.onUpdate = function(position) {
|
||||
keyboard.setFocusPosition(position.x, position.y);
|
||||
};
|
||||
|
@ -102,6 +102,9 @@ function keyPressEvent(event) {
|
|||
keyboard.pressFocussedKey();
|
||||
} else if (event.key === ENTER_CHARCODE || event.key === RETURN_CHARCODE) {
|
||||
keyboard.toggle();
|
||||
if (cursor !== undefined) {
|
||||
cursor.updateVisibility(keyboard.visible);
|
||||
}
|
||||
Overlays.editOverlay(text, {visible: keyboard.visible});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -184,7 +184,7 @@ Keyboard = (function(params) {
|
|||
this.focussed_key = -1;
|
||||
this.scale = (windowDimensions.x / KEYBOARD_WIDTH) * KEYBOARD_SCALE_MULTIPLIER;
|
||||
this.shift = false;
|
||||
this.visible = params.visible != undefined ? params.visible :true;
|
||||
this.visible = params.visible != undefined ? params.visible : true;
|
||||
this.width = function() {
|
||||
return KEYBOARD_WIDTH * tthis.scale;
|
||||
};
|
||||
|
@ -320,21 +320,19 @@ Keyboard = (function(params) {
|
|||
};
|
||||
|
||||
this.show = function() {
|
||||
tthis.visible = true;
|
||||
tthis.updateVisibility();
|
||||
tthis.updateVisibility(true);
|
||||
};
|
||||
|
||||
this.hide = function() {
|
||||
tthis.visible = false;
|
||||
tthis.updateVisibility();
|
||||
tthis.updateVisibility(false);
|
||||
};
|
||||
|
||||
this.toggle = function() {
|
||||
tthis.visible = !tthis.visible;
|
||||
tthis.updateVisibility();
|
||||
tthis.updateVisibility(!tthis.visible);
|
||||
};
|
||||
|
||||
this.updateVisibility = function() {
|
||||
|
||||
this.updateVisibility = function(visible) {
|
||||
tthis.visible = visible;
|
||||
Overlays.editOverlay(tthis.background, { visible: tthis.visible });
|
||||
for (var i = 0; i < this.keys.length; i++) {
|
||||
this.keys[i].updateVisibility();
|
||||
|
@ -454,8 +452,12 @@ Keyboard = (function(params) {
|
|||
this.keyboardTextureLoaded_timer = Script.setInterval(this.keyboardTextureLoaded, 250);
|
||||
});
|
||||
|
||||
Cursor = (function() {
|
||||
Cursor = (function(params) {
|
||||
if (params === undefined) {
|
||||
params = {};
|
||||
}
|
||||
var tthis = this;
|
||||
this.visible = params.visible != undefined ? params.visible : true;
|
||||
this.x = windowDimensions.x / 2;
|
||||
this.y = windowDimensions.y / 2;
|
||||
this.overlay = Overlays.addOverlay("image", {
|
||||
|
@ -464,7 +466,8 @@ Cursor = (function() {
|
|||
width: CURSOR_WIDTH,
|
||||
height: CURSOR_HEIGHT,
|
||||
imageURL: CURSOR_URL,
|
||||
alpha: 1
|
||||
alpha: 1,
|
||||
visible: this.visible
|
||||
});
|
||||
this.remove = function() {
|
||||
Overlays.deleteOverlay(this.overlay);
|
||||
|
@ -478,6 +481,19 @@ Cursor = (function() {
|
|||
this.getY = function() {
|
||||
return tthis.y;
|
||||
};
|
||||
this.show = function() {
|
||||
tthis.updateVisibility(true);
|
||||
};
|
||||
this.hide = function() {
|
||||
tthis.updateVisibility(false);
|
||||
};
|
||||
this.toggle = function() {
|
||||
tthis.updateVisibility(!tthis.visible);
|
||||
};
|
||||
this.updateVisibility = function(visible) {
|
||||
tthis.visible = visible;
|
||||
Overlays.editOverlay(this.overlay, { visible: tthis.visible });
|
||||
};
|
||||
this.onUpdate = null;
|
||||
this.update = function() {
|
||||
var newWindowDimensions = Controller.getViewportDimensions();
|
||||
|
|
Loading…
Reference in a new issue