[Libreoffice-commits] online.git: loleaflet/src

Pranav Kant pranavk at collabora.com
Wed Apr 27 05:48:11 UTC 2016


 loleaflet/src/map/handler/Map.Keyboard.js |   25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

New commits:
commit 0e3e5e023e7e527f918b06bca13b66b229ced9bd
Author: Pranav Kant <pranavk at collabora.com>
Date:   Tue Apr 26 19:57:11 2016 +0530

    loleaflet: Fix AltGr on Windows
    
    On Windows, AltGr events are treated as Alt + Ctrl. Use the
    'location' property to distinguish from plain Alt + Ctrl.
    It is not present in 'keypress' event, so use
    the previous invocation of Alt + Ctrl to detect whether AltGr was
    used or not.
    
    Change-Id: Id6b64b6fc0a5300ea5362880536d3b926eb0acce
    Reviewed-on: https://gerrit.libreoffice.org/24400
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    Tested-by: Andras Timar <andras.timar at collabora.com>
    Reviewed-by: pranavk <pranavk at collabora.com>

diff --git a/loleaflet/src/map/handler/Map.Keyboard.js b/loleaflet/src/map/handler/Map.Keyboard.js
index 9870ed5..44e1594 100644
--- a/loleaflet/src/map/handler/Map.Keyboard.js
+++ b/loleaflet/src/map/handler/Map.Keyboard.js
@@ -233,8 +233,33 @@ L.Map.Keyboard = L.Handler.extend({
 		var ctrl = e.originalEvent.ctrlKey ? this.keyModifier.ctrl : 0;
 		var alt = e.originalEvent.altKey ? this.keyModifier.alt : 0;
 		var cmd = e.originalEvent.metaKey ? this.keyModifier.ctrl : 0;
+		var location = e.originalEvent.location;
 		this.modifier = shift | ctrl | alt | cmd;
 
+		// On Windows, pressing AltGr = Alt + Ctrl
+		// Presence of AltGr is detected if previous Ctrl + Alt 'location' === 2 (i.e right)
+		// because Ctrl + Alt + <some char> won't give any 'location' information.
+		if (ctrl && alt) {
+			if (e.type === 'keydown' && location === 2) {
+				this._prevCtrlAltLocation = location;
+				return;
+			}
+			else if (location === 1) {
+				this._prevCtrlAltLocation = undefined;
+			}
+
+			if (this._prevCtrlAltLocation === 2 && location === 0) {
+				// and we got the final character
+				if (e.type === 'keypress') {
+					ctrl = alt = this.modifier = 0;
+				}
+				else {
+					// Don't handle remnant 'keyup'
+					return;
+				}
+			}
+		}
+
 		if (ctrl || cmd) {
 			if (this._handleCtrlCommand(e)) {
 				return;


More information about the Libreoffice-commits mailing list