/* IE miscalculates width without this :( */
flex-shrink: 0;
}
+#noVNC_canvas:focus {
+ outline: none;
+}
/*Default noVNC logo.*/
/* From: http://fonts.googleapis.com/css?family=Orbitron:700 */
document.documentElement
.addEventListener('mousedown', UI.keepVirtualKeyboard, true);
+ document.documentElement
+ .addEventListener('touchstart', UI.keepVirtualKeyboard, true);
document.getElementById("noVNC_control_bar")
.addEventListener('touchstart', UI.activateControlbar);
addClipboardHandlers: function() {
document.getElementById("noVNC_clipboard_button")
.addEventListener('click', UI.toggleClipboardPanel);
- document.getElementById("noVNC_clipboard_text")
- .addEventListener('focus', UI.displayBlur);
- document.getElementById("noVNC_clipboard_text")
- .addEventListener('blur', UI.displayFocus);
document.getElementById("noVNC_clipboard_text")
.addEventListener('change', UI.clipboardSend);
document.getElementById("noVNC_clipboard_clear_button")
msg = _("Connected (unencrypted) to ") + UI.desktopName;
}
UI.showStatus(msg);
+ document.getElementById('noVNC_canvas').focus();
break;
case 'disconnecting':
UI.connected = false;
}
}
- event.preventDefault();
+ // The default action of touchstart is to generate other
+ // events, which other elements might depend on. So we can't
+ // blindly prevent that. Instead restore focus right away.
+ if (event.type === "touchstart") {
+ setTimeout(input.focus.bind(input));
+ } else {
+ event.preventDefault();
+ }
},
keyboardinputReset: function() {
}
},
- displayBlur: function() {
- if (UI.rfb && !UI.rfb.get_view_only()) {
- UI.rfb.get_keyboard().set_focused(false);
- UI.rfb.get_mouse().set_focused(false);
- }
- },
-
- displayFocus: function() {
- if (UI.rfb && !UI.rfb.get_view_only()) {
- UI.rfb.get_keyboard().set_focused(true);
- UI.rfb.get_mouse().set_focused(true);
- }
- },
-
updateLocalCursor: function() {
if (!UI.rfb) return;
UI.rfb.set_local_cursor(UI.getSetting('cursor'));
this._pendingKey = null; // Key waiting for keypress
set_defaults(this, defaults, {
- 'target': document,
- 'focused': true
+ 'target': null,
});
// keep these here so we can refer to them later
},
_handleKeyDown: function (e) {
- if (!this._focused) { return; }
-
var code = this._getKeyCode(e);
var keysym = KeyboardUtil.getKeysym(e);
// Legacy event for browsers without code/key
_handleKeyPress: function (e) {
- if (!this._focused) { return; }
-
stopEvent(e);
// Are we expecting a keypress?
this._sendKeyEvent(keysym, code, true);
},
_handleKeyPressTimeout: function (e) {
- if (!this._focused) { return; }
-
// Did someone manage to sort out the key already?
if (this._pendingKey === null) {
return;
},
_handleKeyUp: function (e) {
- if (!this._focused) { return; }
-
stopEvent(e);
var code = this._getKeyCode(e);
make_properties(Keyboard, [
['target', 'wo', 'dom'], // DOM element that captures keyboard input
- ['focused', 'rw', 'bool'], // Capture and send key events
['onKeyEvent', 'rw', 'func'] // Handler for key press/release
]);
// Configuration attributes
set_defaults(this, defaults, {
'target': document,
- 'focused': true,
'touchButton': 1
});
},
_handleMouseButton: function (e, down) {
- if (!this._focused) { return; }
-
this._updateMousePosition(e);
var pos = this._pos;
},
_handleMouseWheel: function (e) {
- if (!this._focused || !this._onMouseButton) { return; }
+ if (!this._onMouseButton) { return; }
this._resetWheelStepTimers();
},
_handleMouseMove: function (e) {
- if (! this._focused) { return; }
-
this._updateMousePosition(e);
if (this._onMouseMove) {
this._onMouseMove(this._pos.x, this._pos.y);
},
_handleMouseDisable: function (e) {
- if (!this._focused) { return; }
-
/*
* Stop propagation if inside canvas area
* Note: This is only needed for the 'click' event as it fails
make_properties(Mouse, [
['target', 'ro', 'dom'], // DOM element that captures mouse input
- ['focused', 'rw', 'bool'], // Capture and send mouse clicks/movement
['onMouseButton', 'rw', 'func'], // Handler for mouse button click/release
['onMouseMove', 'rw', 'func'], // Handler for mouse movement
// set the default value on user-facing properties
set_defaults(this, defaults, {
'target': 'null', // VNC display rendering Canvas object
- 'focusContainer': document, // DOM element that captures keyboard input
'encrypt': false, // Use TLS/SSL/wss encryption
'local_cursor': false, // Request locally rendered cursor
'shared': true, // Request shared mode
throw exc;
}
- this._keyboard = new Keyboard({target: this._focusContainer,
+ this._keyboard = new Keyboard({target: this._target,
onKeyEvent: this._handleKeyEvent.bind(this)});
this._mouse = new Mouse({target: this._target,
}
}
+ // Always grab focus on some kind of click event
+ this._target.addEventListener("mousedown", this._focusCanvas);
+ this._target.addEventListener("touchstart", this._focusCanvas);
+
Log.Debug("<< RFB.connect");
},
_disconnect: function () {
Log.Debug(">> RFB.disconnect");
+ this._target.removeEventListener("mousedown", this._focusCanvas);
+ this._target.removeEventListener("touchstart", this._focusCanvas);
this._cleanup();
this._sock.close();
this._print_stats();
}
},
+ // Event handler for canvas so this points to the canvas element
+ _focusCanvas: function(event) {
+ // Respect earlier handlers' request to not do side-effects
+ if (!event.defaultPrevented)
+ this.focus();
+ },
+
/*
* Connection states:
* connecting
make_properties(RFB, [
['target', 'wo', 'dom'], // VNC display rendering Canvas object
- ['focusContainer', 'wo', 'dom'], // DOM element that captures keyboard input
['encrypt', 'rw', 'bool'], // Use TLS/SSL/wss encryption
['local_cursor', 'rw', 'bool'], // Request locally rendered cursor
['shared', 'rw', 'bool'], // Request shared mode
autocorrect="off" autocomplete="off" spellcheck="false"
mozactionhint="Enter"></textarea>
- <canvas id="noVNC_canvas" width="0" height="0">
+ <canvas id="noVNC_canvas" width="0" height="0" tabindex="-1">
Canvas not supported.
</canvas>
</div>