Fix errors on non-touch devices

This commit is contained in:
Juanjo Diaz 2020-01-16 15:22:25 +02:00
parent 30c1485ad8
commit 483f3df789
2 changed files with 18 additions and 8 deletions

View File

@ -88,7 +88,7 @@ const UI = {
// Setup event handlers // Setup event handlers
UI.addControlbarHandlers(); UI.addControlbarHandlers();
UI.addTouchSpecificHandlers(); if (isTouchDevice) { UI.addTouchSpecificHandlers(); }
UI.addExtraKeysHandlers(); UI.addExtraKeysHandlers();
UI.addMachineHandlers(); UI.addMachineHandlers();
UI.addConnectionControlHandlers(); UI.addConnectionControlHandlers();
@ -430,7 +430,7 @@ const UI = {
UI.disableSetting('port'); UI.disableSetting('port');
UI.disableSetting('path'); UI.disableSetting('path');
UI.disableSetting('repeaterID'); UI.disableSetting('repeaterID');
UI.setMouseButton(1); if (isTouchDevice) { UI.setMouseButton(1); }
// Hide the controlbar after 2 seconds // Hide the controlbar after 2 seconds
UI.closeControlbarTimeout = setTimeout(UI.closeControlbar, 2000); UI.closeControlbarTimeout = setTimeout(UI.closeControlbar, 2000);
@ -1661,8 +1661,10 @@ const UI = {
.classList.add('noVNC_hidden'); .classList.add('noVNC_hidden');
document.getElementById('noVNC_toggle_extra_keys_button') document.getElementById('noVNC_toggle_extra_keys_button')
.classList.add('noVNC_hidden'); .classList.add('noVNC_hidden');
document.getElementById('noVNC_mouse_button' + UI.rfb.touchButton) if (isTouchDevice) {
.classList.add('noVNC_hidden'); document.getElementById('noVNC_mouse_button' + UI.rfb.touchButton)
.classList.add('noVNC_hidden');
}
document.getElementById('noVNC_clipboard_button') document.getElementById('noVNC_clipboard_button')
.classList.add('noVNC_hidden'); .classList.add('noVNC_hidden');
} else { } else {
@ -1670,8 +1672,10 @@ const UI = {
.classList.remove('noVNC_hidden'); .classList.remove('noVNC_hidden');
document.getElementById('noVNC_toggle_extra_keys_button') document.getElementById('noVNC_toggle_extra_keys_button')
.classList.remove('noVNC_hidden'); .classList.remove('noVNC_hidden');
document.getElementById('noVNC_mouse_button' + UI.rfb.touchButton) if (isTouchDevice) {
.classList.remove('noVNC_hidden'); document.getElementById('noVNC_mouse_button' + UI.rfb.touchButton)
.classList.remove('noVNC_hidden');
}
document.getElementById('noVNC_clipboard_button') document.getElementById('noVNC_clipboard_button')
.classList.remove('noVNC_hidden'); .classList.remove('noVNC_hidden');
} }

View File

@ -311,8 +311,14 @@ export default class RFB extends EventTargetMixin {
get capabilities() { return this._capabilities; } get capabilities() { return this._capabilities; }
get touchButton() { return this._touch.touchButton; } get touchButton() {
set touchButton(button) { this._touch.touchButton = button; } if (!this._touch) { return null; }
return this._touch.touchButton;
}
set touchButton(button) {
if (!this._touch) { return; }
this._touch.touchButton = button;
}
get clipViewport() { return this._clipViewport; } get clipViewport() { return this._clipViewport; }
set clipViewport(viewport) { set clipViewport(viewport) {