wasm: send key release for touchscreen input

Fixes: QTBUG-114203
Pick-to: 6.6 6.5
Change-Id: I117ce857484520167d0c0166280dd604c139ff03
Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
This commit is contained in:
Lorn Potter 2023-06-23 16:54:33 +10:00
parent 087d267a44
commit eda0ccb36b
2 changed files with 8 additions and 5 deletions

View File

@ -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)
{

View File

@ -40,7 +40,7 @@ private:
emscripten::val m_inputElement = emscripten::val::null();
std::unique_ptr<qstdweb::EventCallback> m_blurEventHandler;
std::unique_ptr<qstdweb::EventCallback> m_inputEventHandler;
static int androidKeyboardCallback(int eventType,
static int inputMethodKeyboardCallback(int eventType,
const EmscriptenKeyboardEvent *keyEvent, void *userData);
bool inputPanelIsOpen = false;
};