wasm: fix linux touchscreen keyboard input

Fixes: QTBUG-124366
Change-Id: I9bd83ecb75b94efbf12b13055e292a74e6e9edcd
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
(cherry picked from commit d374dd6f84c74e6e0adf441f19af31a31074f7ec)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Lorn Potter 2024-04-15 13:53:18 +10:00 committed by Qt Cherry-pick Bot
parent d40f29353e
commit 5f7324b20e

View File

@ -49,7 +49,15 @@ QWasmInputContext::QWasmInputContext()
m_inputElement.set("style", "position:absolute;left:-1000px;top:-1000px"); // offscreen
m_inputElement.set("contenteditable","true");
if (platform() == Platform::Android || platform() == Platform::Windows) {
if (platform() == Platform::MacOS || platform() == Platform::iOS) {
auto callback = [=](emscripten::val) {
m_inputElement["parentElement"].call<void>("removeChild", m_inputElement);
inputPanelIsOpen = false;
};
m_blurEventHandler.reset(new EventCallback(m_inputElement, "blur", callback));
} else {
const std::string inputType = platform() == Platform::Windows ? "textInput" : "input";
document.call<void>("addEventListener", inputType,
@ -61,14 +69,6 @@ QWasmInputContext::QWasmInputContext()
body.call<void>("appendChild", m_inputElement);
}
if (platform() == Platform::MacOS || platform() == Platform::iOS) {
auto callback = [=](emscripten::val) {
m_inputElement["parentElement"].call<void>("removeChild", m_inputElement);
inputPanelIsOpen = false;
};
m_blurEventHandler.reset(new EventCallback(m_inputElement, "blur", callback));
}
QObject::connect(qGuiApp, &QGuiApplication::focusWindowChanged, this,
&QWasmInputContext::focusWindowChanged);
}