wasm: remove 'shift' from being inputed on touchscreens
Fixes: QTBUG-116231 Change-Id: Icbbe80877c2c21c3e82ba2c27909b6679b72e498 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> (cherry picked from commit 91d3c48d3da5f75e126bbce79096a84c078e23e2) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
8240f9437e
commit
883a12d28d
@ -30,7 +30,7 @@ static void inputCallback(emscripten::val event)
|
|||||||
QString str = QString::fromStdString(_incomingCharVal.as<std::string>());
|
QString str = QString::fromStdString(_incomingCharVal.as<std::string>());
|
||||||
QWasmInputContext *wasmInput =
|
QWasmInputContext *wasmInput =
|
||||||
reinterpret_cast<QWasmInputContext*>(event["target"]["data-qinputcontext"].as<quintptr>());
|
reinterpret_cast<QWasmInputContext*>(event["target"]["data-qinputcontext"].as<quintptr>());
|
||||||
wasmInput->inputStringChanged(str, wasmInput);
|
wasmInput->inputStringChanged(str, EMSCRIPTEN_EVENT_KEYDOWN, wasmInput);
|
||||||
}
|
}
|
||||||
// this clears the input string, so backspaces do not send a character
|
// this clears the input string, so backspaces do not send a character
|
||||||
// but stops suggestions
|
// but stops suggestions
|
||||||
@ -138,13 +138,26 @@ void QWasmInputContext::hideInputPanel()
|
|||||||
inputPanelIsOpen = false;
|
inputPanelIsOpen = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWasmInputContext::inputStringChanged(QString &inputString, QWasmInputContext *context)
|
void QWasmInputContext::inputStringChanged(QString &inputString, int eventType, QWasmInputContext *context)
|
||||||
{
|
{
|
||||||
Q_UNUSED(context)
|
Q_UNUSED(context)
|
||||||
QKeySequence keys = QKeySequence::fromString(inputString);
|
QKeySequence keys = QKeySequence::fromString(inputString);
|
||||||
|
Qt::Key thisKey = keys[0].key();
|
||||||
|
|
||||||
// synthesize this keyevent as android is not normal
|
// synthesize this keyevent as android is not normal
|
||||||
|
if (inputString.size() > 2 && (thisKey < Qt::Key_F35
|
||||||
|
|| thisKey > Qt::Key_Back)) {
|
||||||
|
inputString.clear();
|
||||||
|
}
|
||||||
|
if (inputString == QStringLiteral("Escape")) {
|
||||||
|
thisKey = Qt::Key_Escape;
|
||||||
|
inputString.clear();
|
||||||
|
} else if (thisKey == Qt::Key(0)) {
|
||||||
|
thisKey = Qt::Key_Return;
|
||||||
|
}
|
||||||
QWindowSystemInterface::handleKeyEvent(
|
QWindowSystemInterface::handleKeyEvent(
|
||||||
0, QEvent::KeyPress,keys[0].key(), keys[0].keyboardModifiers(), inputString);
|
0, eventType == EMSCRIPTEN_EVENT_KEYDOWN ? QEvent::KeyPress : QEvent::KeyRelease,
|
||||||
|
thisKey, keys[0].keyboardModifiers(), inputString);
|
||||||
}
|
}
|
||||||
|
|
||||||
int QWasmInputContext::androidKeyboardCallback(int eventType,
|
int QWasmInputContext::androidKeyboardCallback(int eventType,
|
||||||
@ -152,13 +165,12 @@ int QWasmInputContext::androidKeyboardCallback(int eventType,
|
|||||||
void *userData)
|
void *userData)
|
||||||
{
|
{
|
||||||
// we get Enter, Backspace and function keys via emscripten on target window
|
// we get Enter, Backspace and function keys via emscripten on target window
|
||||||
Q_UNUSED(eventType)
|
|
||||||
QString strKey(keyEvent->key);
|
QString strKey(keyEvent->key);
|
||||||
if (strKey == "Unidentified" || strKey == "Process")
|
if (strKey == "Unidentified" || strKey == "Process")
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
QWasmInputContext *wasmInput = reinterpret_cast<QWasmInputContext*>(userData);
|
QWasmInputContext *wasmInput = reinterpret_cast<QWasmInputContext*>(userData);
|
||||||
wasmInput->inputStringChanged(strKey, wasmInput);
|
wasmInput->inputStringChanged(strKey, eventType, wasmInput);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ public:
|
|||||||
bool isValid() const override { return true; }
|
bool isValid() const override { return true; }
|
||||||
|
|
||||||
void focusWindowChanged(QWindow *focusWindow);
|
void focusWindowChanged(QWindow *focusWindow);
|
||||||
void inputStringChanged(QString &, QWasmInputContext *context);
|
void inputStringChanged(QString &, int eventType, QWasmInputContext *context);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
emscripten::val inputHandlerElementForFocusedWindow();
|
emscripten::val inputHandlerElementForFocusedWindow();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user