wasm: fix unicode input
also remove duplicated function call to get Qt key for event Pick-to: 6.3 6.4 Fixes: QTBUG-78826 Change-Id: Ibaf0dd3eb428b65280ed1f840a4849b44f2868e0 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
This commit is contained in:
parent
81b5395aef
commit
87c2a401da
@ -1138,8 +1138,8 @@ bool QWasmCompositor::processKeyboard(int eventType, const EmscriptenKeyboardEve
|
||||
case EMSCRIPTEN_EVENT_KEYPRESS:
|
||||
case EMSCRIPTEN_EVENT_KEYDOWN: // down
|
||||
keyType = QEvent::KeyPress;
|
||||
keyText = this->eventTranslator->getKeyText(keyEvent);
|
||||
qtKey = this->eventTranslator->getKey(keyEvent);
|
||||
keyText = this->eventTranslator->getKeyText(keyEvent, qtKey);
|
||||
break;
|
||||
case EMSCRIPTEN_EVENT_KEYUP: // up
|
||||
keyType = QEvent::KeyRelease;
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <private/qmakearray_p.h>
|
||||
#include <QtCore/qnamespace.h>
|
||||
#include <QCursor>
|
||||
#include <QtCore/private/qstringiterator_p.h>
|
||||
|
||||
#include <emscripten/bind.h>
|
||||
|
||||
@ -229,9 +230,9 @@ Qt::Key QWasmEventTranslator::translateEmscriptKey(const EmscriptenKeyboardEvent
|
||||
|
||||
if (qtKey == Qt::Key_unknown) {
|
||||
// cast to unicode key
|
||||
QString str = QString::fromUtf8(emscriptKey->key);
|
||||
ushort c = str.unicode()->toUpper().unicode(); // uppercase
|
||||
qtKey = static_cast<Qt::Key>(c);
|
||||
QString str = QString::fromUtf8(emscriptKey->key).toUpper();
|
||||
QStringIterator i(str);
|
||||
qtKey = static_cast<Qt::Key>(i.next(0));
|
||||
}
|
||||
|
||||
return qtKey;
|
||||
@ -364,11 +365,9 @@ QCursor QWasmEventTranslator::cursorForMode(QWasmCompositor::ResizeMode m)
|
||||
return Qt::ArrowCursor;
|
||||
}
|
||||
|
||||
QString QWasmEventTranslator::getKeyText(const EmscriptenKeyboardEvent *keyEvent)
|
||||
QString QWasmEventTranslator::getKeyText(const EmscriptenKeyboardEvent *keyEvent, Qt::Key qtKey)
|
||||
{
|
||||
QString keyText;
|
||||
Qt::Key qtKey = translateEmscriptKey(keyEvent);
|
||||
//Qt::KeyboardModifiers modifiers = translateKeyboardEventModifier(keyEvent);
|
||||
|
||||
if (m_emDeadKey != Qt::Key_unknown) {
|
||||
Qt::Key transformedKey = translateDeadKey(m_emDeadKey, qtKey);
|
||||
@ -394,7 +393,8 @@ QString QWasmEventTranslator::getKeyText(const EmscriptenKeyboardEvent *keyEvent
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (keyText.isEmpty())
|
||||
keyText = QString::fromUtf8(keyEvent->key);
|
||||
return keyText;
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ public:
|
||||
static Qt::MouseButton translateMouseButton(unsigned short button);
|
||||
static QCursor cursorForMode(QWasmCompositor::ResizeMode mode);
|
||||
|
||||
QString getKeyText(const EmscriptenKeyboardEvent *keyEvent);
|
||||
QString getKeyText(const EmscriptenKeyboardEvent *keyEvent, Qt::Key key);
|
||||
Qt::Key getKey(const EmscriptenKeyboardEvent *keyEvent);
|
||||
void setStickyDeadKey(const EmscriptenKeyboardEvent *keyEvent);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user