canvas.js: prevent Opera keyboard event bubbling.
Issue #8: https://github.com/kanaka/noVNC/issues#issue/8
This commit is contained in:
parent
b43c9838a5
commit
cabecf8964
|
@ -291,6 +291,17 @@ function onKeyUp(e) {
|
|||
return false;
|
||||
}
|
||||
|
||||
function onKeyPress(e) {
|
||||
//Util.Debug("keypress: " + e.charCode);
|
||||
if (! conf.focused) {
|
||||
return true;
|
||||
}
|
||||
// Stop keypress events. Necessary for Opera because stopping
|
||||
// keydown and keyup events still results in a keypress event.
|
||||
Util.stopEvent(e);
|
||||
return false;
|
||||
}
|
||||
|
||||
function onMouseDisable(e) {
|
||||
var evt, pos;
|
||||
if (! conf.focused) {
|
||||
|
@ -328,6 +339,7 @@ that.start = function(keyPressFunc, mouseButtonFunc, mouseMoveFunc) {
|
|||
|
||||
Util.addEvent(conf.focusContainer, 'keydown', onKeyDown);
|
||||
Util.addEvent(conf.focusContainer, 'keyup', onKeyUp);
|
||||
Util.addEvent(conf.focusContainer, 'keypress', onKeyPress);
|
||||
Util.addEvent(c, 'mousedown', onMouseDown);
|
||||
Util.addEvent(c, 'mouseup', onMouseUp);
|
||||
Util.addEvent(c, 'mousemove', onMouseMove);
|
||||
|
@ -341,6 +353,27 @@ that.start = function(keyPressFunc, mouseButtonFunc, mouseMoveFunc) {
|
|||
Util.Debug("<< Canvas.start");
|
||||
};
|
||||
|
||||
that.stop = function() {
|
||||
var c = conf.target;
|
||||
Util.removeEvent(conf.focusContainer, 'keydown', onKeyDown);
|
||||
Util.removeEvent(conf.focusContainer, 'keyup', onKeyUp);
|
||||
Util.removeEvent(conf.focusContainer, 'keypress', onKeyPress);
|
||||
Util.removeEvent(c, 'mousedown', onMouseDown);
|
||||
Util.removeEvent(c, 'mouseup', onMouseUp);
|
||||
Util.removeEvent(c, 'mousemove', onMouseMove);
|
||||
Util.removeEvent(c, (Util.Engine.gecko) ? 'DOMMouseScroll' : 'mousewheel',
|
||||
onMouseWheel);
|
||||
|
||||
/* Work around right and middle click browser behaviors */
|
||||
Util.removeEvent(conf.focusContainer, 'click', onMouseDisable);
|
||||
Util.removeEvent(conf.focusContainer.body, 'contextmenu', onMouseDisable);
|
||||
|
||||
// Turn off cursor rendering
|
||||
if (conf.cursor_uri) {
|
||||
c.style.cursor = "default";
|
||||
}
|
||||
};
|
||||
|
||||
that.rescale = function(factor) {
|
||||
var c, tp, x, y,
|
||||
properties = ['transform', 'WebkitTransform', 'MozTransform', null];
|
||||
|
@ -394,26 +427,6 @@ that.clear = function() {
|
|||
//conf.ctx.globalCompositeOperation = "copy";
|
||||
};
|
||||
|
||||
that.stop = function() {
|
||||
var c = conf.target;
|
||||
Util.removeEvent(conf.focusContainer, 'keydown', onKeyDown);
|
||||
Util.removeEvent(conf.focusContainer, 'keyup', onKeyUp);
|
||||
Util.removeEvent(c, 'mousedown', onMouseDown);
|
||||
Util.removeEvent(c, 'mouseup', onMouseUp);
|
||||
Util.removeEvent(c, 'mousemove', onMouseMove);
|
||||
Util.removeEvent(c, (Util.Engine.gecko) ? 'DOMMouseScroll' : 'mousewheel',
|
||||
onMouseWheel);
|
||||
|
||||
/* Work around right and middle click browser behaviors */
|
||||
Util.removeEvent(conf.focusContainer, 'click', onMouseDisable);
|
||||
Util.removeEvent(conf.focusContainer.body, 'contextmenu', onMouseDisable);
|
||||
|
||||
// Turn off cursor rendering
|
||||
if (conf.cursor_uri) {
|
||||
c.style.cursor = "default";
|
||||
}
|
||||
};
|
||||
|
||||
that.flush = function() {
|
||||
var old_val;
|
||||
//Util.Debug(">> flush");
|
||||
|
@ -706,9 +719,7 @@ function changeCursor(target, pixels, mask, hotx, hoty, w, h, cmap) {
|
|||
}
|
||||
|
||||
url = "data:image/x-icon;base64," + Base64.encode(cur);
|
||||
Util.Info(url);
|
||||
target.style.cursor = "url(" + url + ") " + hotx + " " + hoty + ", default";
|
||||
//conf.target.style.cursor = "url(" + url + "), default";
|
||||
//Util.Debug("<< changeCursor, cur.length: " + cur.length);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue