From 0f5690c5a27d72ebcf3d31d0f67ee281586e8ff1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20S=C3=B8rvig?= Date: Tue, 8 Apr 2025 16:49:37 +0200 Subject: [PATCH] wasm: port rest of input context event handlers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Follow-up to 13e92283, change the clipboard event handlers to use QWasmEventHandler as well. The removed addEventListener calls set capturing to false, but this is already the default (also for QWasmEventHandler), Change-Id: Ibecaa22099fecd371a5d243cf391d3ce6f562400 Reviewed-by: Piotr WierciƄski Reviewed-by: Even Oscar Andersen --- .../platforms/wasm/qwasminputcontext.cpp | 19 +++---------------- .../platforms/wasm/qwasminputcontext.h | 4 ++++ 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/plugins/platforms/wasm/qwasminputcontext.cpp b/src/plugins/platforms/wasm/qwasminputcontext.cpp index 1eb59aaa7f2..56cb7c032d8 100644 --- a/src/plugins/platforms/wasm/qwasminputcontext.cpp +++ b/src/plugins/platforms/wasm/qwasminputcontext.cpp @@ -231,13 +231,6 @@ static void pasteCallback(emscripten::val event) // propagate to input event (insertFromPaste) } -EMSCRIPTEN_BINDINGS(wasminputcontext_module) { - - function("qtCopyCallback", ©Callback); - function("qtCutCallback", &cutCallback); - function("qtPasteCallback", &pasteCallback); -} - QWasmInputContext::QWasmInputContext() { qCDebug(qLcQpaWasmInputContext) << Q_FUNC_INFO; @@ -266,15 +259,9 @@ QWasmInputContext::QWasmInputContext() m_compositionUpdateCallback = QWasmEventHandler(m_inputElement, "compositionupdate", QWasmInputContext::compositionUpdateCallback); // Clipboard for InputContext - m_inputElement.call("addEventListener", std::string("cut"), - emscripten::val::module_property("qtCutCallback"), - emscripten::val(false)); - m_inputElement.call("addEventListener", std::string("copy"), - emscripten::val::module_property("qtCopyCallback"), - emscripten::val(false)); - m_inputElement.call("addEventListener", std::string("paste"), - emscripten::val::module_property("qtPasteCallback"), - emscripten::val(false)); + m_clipboardCut = QWasmEventHandler(m_inputElement, "cut", cutCallback); + m_clipboardCopy = QWasmEventHandler(m_inputElement, "copy", copyCallback); + m_clipboardPaste = QWasmEventHandler(m_inputElement, "paste", pasteCallback); } QWasmInputContext::~QWasmInputContext() diff --git a/src/plugins/platforms/wasm/qwasminputcontext.h b/src/plugins/platforms/wasm/qwasminputcontext.h index 3c38412adaf..a5b540dae23 100644 --- a/src/plugins/platforms/wasm/qwasminputcontext.h +++ b/src/plugins/platforms/wasm/qwasminputcontext.h @@ -55,6 +55,10 @@ private: void updateInputElement(); private: + QWasmEventHandler m_clipboardCut; + QWasmEventHandler m_clipboardCopy; + QWasmEventHandler m_clipboardPaste; + QString m_preeditString; int m_replaceSize = 0;