From eda0ccb36baae10784f71552408148f095d25953 Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Fri, 23 Jun 2023 16:54:33 +1000 Subject: [PATCH] wasm: send key release for touchscreen input MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: QTBUG-114203 Pick-to: 6.6 6.5 Change-Id: I117ce857484520167d0c0166280dd604c139ff03 Reviewed-by: Piotr Wierciński Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/wasm/qwasminputcontext.cpp | 11 +++++++---- src/plugins/platforms/wasm/qwasminputcontext.h | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/plugins/platforms/wasm/qwasminputcontext.cpp b/src/plugins/platforms/wasm/qwasminputcontext.cpp index f2c4c93fe4d..25b37e6930a 100644 --- a/src/plugins/platforms/wasm/qwasminputcontext.cpp +++ b/src/plugins/platforms/wasm/qwasminputcontext.cpp @@ -62,8 +62,9 @@ QWasmInputContext::QWasmInputContext() // Enter is sent through target window, let's just handle this here emscripten_set_keydown_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, (void *)this, 1, - &androidKeyboardCallback); - + &inputMethodKeyboardCallback); + emscripten_set_keyup_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, (void *)this, 1, + &inputMethodKeyboardCallback); } if (platform() == Platform::MacOS || platform() == Platform::iOS) { @@ -155,12 +156,14 @@ void QWasmInputContext::inputStringChanged(QString &inputString, int eventType, } else if (thisKey == Qt::Key(0)) { thisKey = Qt::Key_Return; } + QWindowSystemInterface::handleKeyEvent( 0, eventType == EMSCRIPTEN_EVENT_KEYDOWN ? QEvent::KeyPress : QEvent::KeyRelease, - thisKey, keys[0].keyboardModifiers(), inputString); + thisKey, keys[0].keyboardModifiers(), + eventType == EMSCRIPTEN_EVENT_KEYDOWN ? inputString : QStringLiteral("")); } -int QWasmInputContext::androidKeyboardCallback(int eventType, +int QWasmInputContext::inputMethodKeyboardCallback(int eventType, const EmscriptenKeyboardEvent *keyEvent, void *userData) { diff --git a/src/plugins/platforms/wasm/qwasminputcontext.h b/src/plugins/platforms/wasm/qwasminputcontext.h index 7e07220bd2b..eb840742fc9 100644 --- a/src/plugins/platforms/wasm/qwasminputcontext.h +++ b/src/plugins/platforms/wasm/qwasminputcontext.h @@ -40,7 +40,7 @@ private: emscripten::val m_inputElement = emscripten::val::null(); std::unique_ptr m_blurEventHandler; std::unique_ptr m_inputEventHandler; - static int androidKeyboardCallback(int eventType, + static int inputMethodKeyboardCallback(int eventType, const EmscriptenKeyboardEvent *keyEvent, void *userData); bool inputPanelIsOpen = false; };