mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 21:27:40 +00:00
More migration to traditional JS events.
This commit is contained in:
@@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
function GuacamoleKeyboard(element) {
|
function GuacamoleKeyboard(element) {
|
||||||
|
|
||||||
|
var guac_keyboard = this;
|
||||||
|
|
||||||
// Keymap
|
// Keymap
|
||||||
|
|
||||||
var unshiftedKeySym = new Array();
|
var unshiftedKeySym = new Array();
|
||||||
@@ -64,11 +66,6 @@ function GuacamoleKeyboard(element) {
|
|||||||
var shiftedKeySym = new Array();
|
var shiftedKeySym = new Array();
|
||||||
shiftedKeySym[18] = 0xFFE7; // alt
|
shiftedKeySym[18] = 0xFFE7; // alt
|
||||||
|
|
||||||
|
|
||||||
/*****************************************/
|
|
||||||
/*** Keyboard Handler ***/
|
|
||||||
/*****************************************/
|
|
||||||
|
|
||||||
// Single key state/modifier buffer
|
// Single key state/modifier buffer
|
||||||
var modShift = 0;
|
var modShift = 0;
|
||||||
var modCtrl = 0;
|
var modCtrl = 0;
|
||||||
@@ -150,14 +147,14 @@ function GuacamoleKeyboard(element) {
|
|||||||
|
|
||||||
// Sends a single keystroke over the network
|
// Sends a single keystroke over the network
|
||||||
function sendKeyPressed(keysym) {
|
function sendKeyPressed(keysym) {
|
||||||
if (keysym != null && keyPressedHandler)
|
if (keysym != null && guac_keyboard.onkeydown)
|
||||||
keyPressedHandler(keysym);
|
guac_keyboard.onkeydown(keysym);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sends a single keystroke over the network
|
// Sends a single keystroke over the network
|
||||||
function sendKeyReleased(keysym) {
|
function sendKeyReleased(keysym) {
|
||||||
if (keysym != null)
|
if (keysym != null && guac_keyboard.onkeyup)
|
||||||
keyReleasedHandler(keysym);
|
guac_keyboard.onkeyup(keysym);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -171,7 +168,7 @@ function GuacamoleKeyboard(element) {
|
|||||||
element.onkeydown = function(e) {
|
element.onkeydown = function(e) {
|
||||||
|
|
||||||
// Only intercept if handler set
|
// Only intercept if handler set
|
||||||
if (!keyPressedHandler) return true;
|
if (!guac_keyboard.onkeydown) return true;
|
||||||
|
|
||||||
var keynum;
|
var keynum;
|
||||||
if (window.event) keynum = window.event.keyCode;
|
if (window.event) keynum = window.event.keyCode;
|
||||||
@@ -237,7 +234,7 @@ function GuacamoleKeyboard(element) {
|
|||||||
element.onkeypress = function(e) {
|
element.onkeypress = function(e) {
|
||||||
|
|
||||||
// Only intercept if handler set
|
// Only intercept if handler set
|
||||||
if (!keyPressedHandler) return true;
|
if (!guac_keyboard.onkeydown) return true;
|
||||||
|
|
||||||
if (keySymSource != KEYPRESS) return false;
|
if (keySymSource != KEYPRESS) return false;
|
||||||
|
|
||||||
@@ -272,7 +269,7 @@ function GuacamoleKeyboard(element) {
|
|||||||
element.onkeyup = function(e) {
|
element.onkeyup = function(e) {
|
||||||
|
|
||||||
// Only intercept if handler set
|
// Only intercept if handler set
|
||||||
if (!keyReleasedHandler) return true;
|
if (!guac_keyboard.onkeyup) return true;
|
||||||
|
|
||||||
var keynum;
|
var keynum;
|
||||||
if (window.event) keynum = window.event.keyCode;
|
if (window.event) keynum = window.event.keyCode;
|
||||||
@@ -309,10 +306,7 @@ function GuacamoleKeyboard(element) {
|
|||||||
if (docOnblur != null) docOnblur();
|
if (docOnblur != null) docOnblur();
|
||||||
};
|
};
|
||||||
|
|
||||||
var keyPressedHandler = null;
|
guac_keyboard.onkeydown = null;
|
||||||
var keyReleasedHandler = null;
|
guac_keyboard.onkeyup = null;
|
||||||
|
|
||||||
this.setKeyPressedHandler = function(kh) { keyPressedHandler = kh; };
|
|
||||||
this.setKeyReleasedHandler = function(kh) { keyReleasedHandler = kh; };
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -20,12 +20,7 @@
|
|||||||
|
|
||||||
function GuacamoleMouse(element) {
|
function GuacamoleMouse(element) {
|
||||||
|
|
||||||
/*****************************************/
|
var guac_mouse = this;
|
||||||
/*** Mouse Handler ***/
|
|
||||||
/*****************************************/
|
|
||||||
|
|
||||||
|
|
||||||
var mouseIndex = 0;
|
|
||||||
|
|
||||||
var mouseLeftButton = 0;
|
var mouseLeftButton = 0;
|
||||||
var mouseMiddleButton = 0;
|
var mouseMiddleButton = 0;
|
||||||
@@ -69,7 +64,8 @@ function GuacamoleMouse(element) {
|
|||||||
parent = parent.offsetParent;
|
parent = parent.offsetParent;
|
||||||
}
|
}
|
||||||
|
|
||||||
movementHandler(getMouseState(0, 0));
|
if (guac_mouse.onmousemove)
|
||||||
|
guac_mouse.onmousemove(getMouseState(0, 0));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -89,7 +85,8 @@ function GuacamoleMouse(element) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
buttonPressedHandler(getMouseState(0, 0));
|
if (guac_mouse.onmousedown)
|
||||||
|
guac_mouse.onmousedown(getMouseState(0, 0));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -109,7 +106,8 @@ function GuacamoleMouse(element) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
buttonReleasedHandler(getMouseState(0, 0));
|
if (guac_mouse.onmouseup)
|
||||||
|
guac_mouse.onmouseup(getMouseState(0, 0));
|
||||||
};
|
};
|
||||||
|
|
||||||
element.onmouseout = function(e) {
|
element.onmouseout = function(e) {
|
||||||
@@ -122,7 +120,8 @@ function GuacamoleMouse(element) {
|
|||||||
mouseMiddleButton = 0;
|
mouseMiddleButton = 0;
|
||||||
mouseRightButton = 0;
|
mouseRightButton = 0;
|
||||||
|
|
||||||
buttonReleasedHandler(getMouseState(0, 0));
|
if (guac_mouse.onmouseup)
|
||||||
|
guac_mouse.onmouseup(getMouseState(0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -143,14 +142,20 @@ function GuacamoleMouse(element) {
|
|||||||
|
|
||||||
// Up
|
// Up
|
||||||
if (delta < 0) {
|
if (delta < 0) {
|
||||||
buttonPressedHandler(getMouseState(1, 0));
|
if (guac_mouse.onmousedown)
|
||||||
buttonReleasedHandler(getMouseState(0, 0));
|
guac_mouse.onmousedown(getMouseState(1, 0));
|
||||||
|
|
||||||
|
if (guac_mouse.onmouseup)
|
||||||
|
guac_mouse.onmouseup(getMouseState(0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Down
|
// Down
|
||||||
if (delta > 0) {
|
if (delta > 0) {
|
||||||
buttonPressedHandler(getMouseState(0, 1));
|
if (guac_mouse.onmousedown)
|
||||||
buttonReleasedHandler(getMouseState(0, 0));
|
guac_mouse.onmousedown(getMouseState(0, 1));
|
||||||
|
|
||||||
|
if (guac_mouse.onmouseup)
|
||||||
|
guac_mouse.onmouseup(getMouseState(0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.preventDefault)
|
if (e.preventDefault)
|
||||||
@@ -165,20 +170,15 @@ function GuacamoleMouse(element) {
|
|||||||
handleScroll(e);
|
handleScroll(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
var buttonPressedHandler = null;
|
guac_mouse.onmousedown = null;
|
||||||
var buttonReleasedHandler = null;
|
guac_mouse.onmouseup = null;
|
||||||
var movementHandler = null;
|
guac_mouse.onmousemove = null;
|
||||||
|
|
||||||
this.setButtonPressedHandler = function(mh) {buttonPressedHandler = mh;};
|
guac_mouse.getX = function() {return mouseX;};
|
||||||
this.setButtonReleasedHandler = function(mh) {buttonReleasedHandler = mh;};
|
guac_mouse.getY = function() {return mouseY;};
|
||||||
this.setMovementHandler = function(mh) {movementHandler = mh;};
|
guac_mouse.getLeftButton = function() {return mouseLeftButton;};
|
||||||
|
guac_mouse.getMiddleButton = function() {return mouseMiddleButton;};
|
||||||
|
guac_mouse.getRightButton = function() {return mouseRightButton;};
|
||||||
this.getX = function() {return mouseX;};
|
|
||||||
this.getY = function() {return mouseY;};
|
|
||||||
this.getLeftButton = function() {return mouseLeftButton;};
|
|
||||||
this.getMiddleButton = function() {return mouseMiddleButton;};
|
|
||||||
this.getRightButton = function() {return mouseRightButton;};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user