Console catches keyboard and mouse inputs only when mouse is hovering.

Also, when the mouse enters the VM screen, the current active element is unfocused.
This commit is contained in:
Pierre
2015-11-26 13:55:45 +01:00
parent afe589dec3
commit aa27492713
2 changed files with 18 additions and 0 deletions

View File

@@ -122,6 +122,22 @@ export default angular.module('no-vnc', [])
let canvas = $element.find('canvas')[0]
$scope.unfocus = () => {
if (rfb) {
rfb.get_keyboard().ungrab()
rfb.get_mouse().ungrab()
}
}
$scope.focus = () => {
if (rfb) {
if (document.activeElement) {
document.activeElement.blur()
}
rfb.get_keyboard().grab()
rfb.get_mouse().grab()
}
}
$attrs.$observe('url', (url) => {
reset(url)
})

View File

@@ -1,5 +1,7 @@
canvas.center-block(
height = "{{noVnc.height}}"
width = "{{noVnc.width}}"
ng-mouseenter = 'focus()'
ng-mouseleave = 'unfocus()'
)
| Sorry, your browser does not support the canvas element.