wasm: port rest of input context event handlers

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 <piotr.wiercinski@qt.io>
Reviewed-by: Even Oscar Andersen <even.oscar.andersen@qt.io>
This commit is contained in:
Morten Sørvig 2025-04-08 16:49:37 +02:00
parent a4aac362cf
commit 0f5690c5a2
2 changed files with 7 additions and 16 deletions

View File

@ -231,13 +231,6 @@ static void pasteCallback(emscripten::val event)
// propagate to input event (insertFromPaste)
}
EMSCRIPTEN_BINDINGS(wasminputcontext_module) {
function("qtCopyCallback", &copyCallback);
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<void>("addEventListener", std::string("cut"),
emscripten::val::module_property("qtCutCallback"),
emscripten::val(false));
m_inputElement.call<void>("addEventListener", std::string("copy"),
emscripten::val::module_property("qtCopyCallback"),
emscripten::val(false));
m_inputElement.call<void>("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()

View File

@ -55,6 +55,10 @@ private:
void updateInputElement();
private:
QWasmEventHandler m_clipboardCut;
QWasmEventHandler m_clipboardCopy;
QWasmEventHandler m_clipboardPaste;
QString m_preeditString;
int m_replaceSize = 0;