From a5373486aac67e810669107ac1e6aed8d1c6869a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Sun, 24 Mar 2024 08:36:08 +0100 Subject: [PATCH] fix: stop propagation of key events Closes: https://github.com/cheminfo/openchemlib-js/issues/196 --- src/com/actelion/research/gwt/gui/editor/DrawArea.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/com/actelion/research/gwt/gui/editor/DrawArea.java b/src/com/actelion/research/gwt/gui/editor/DrawArea.java index b2d20992..540845dd 100644 --- a/src/com/actelion/research/gwt/gui/editor/DrawArea.java +++ b/src/com/actelion/research/gwt/gui/editor/DrawArea.java @@ -307,10 +307,12 @@ public void onKeyDown(KeyDownEvent event) { meta = event.isMetaKeyDown() || event.isControlKeyDown(); code = event.getNativeKeyCode(); if (!meta && isValidKey(code)) { + event.stopPropagation(); event.preventDefault(); } else if (meta) { if (code == KeyCodes.KEY_C) { copyMolecule(); + event.stopPropagation(); event.preventDefault(); } } @@ -321,6 +323,7 @@ public void onKeyDown(KeyDownEvent event) { public void onKeyUp(KeyUpEvent event) { code = event.getNativeKeyCode(); if (!meta && isValidKey(code)) { + event.stopPropagation(); event.preventDefault(); handler.onKey(new ACTKeyEvent(code, event, // .isShiftKeyDown(), pressed ? (ACTKeyEvent.LETTER | ACTKeyEvent.DIGIT) : 0)); @@ -335,6 +338,7 @@ public void onKeyPress(KeyPressEvent event) { pressed = true; code = event.getCharCode(); if (isValidKey(code)) { + event.stopPropagation(); event.preventDefault(); } }