diff options
| author | Morten Sørvig <[email protected]> | 2025-07-04 16:14:03 +0200 | 
|---|---|---|
| committer | Morten Sørvig <[email protected]> | 2025-07-16 15:54:22 +0200 | 
| commit | e61a3f8e870bc91fb5e1107f8a608582a93d952e (patch) | |
| tree | 2353f6018281f09a9f242d33994b413cc33c5279 | |
| parent | 1b24cfdac501bae99cc1e34a995ab78d18badd92 (diff) | |
wasm: move setting of input type to updateInputElement()
This is after we set m_inputElement to focusWindow->inputElement(),
at this point m_inputElement should be the correct input
element.
Simplify the implementation a bit:
- don't check if the focused UI element accepts complex input,
  we are only interested if it's a passoword-type input or not
  here.
- set "type" unconditionally, which avoids a crash on "type"
  not defined, which started happening after recent refactorings.
Pick-to: 6.10
Change-Id: Iba342e7adcacdaa6a3d7b7f7e9c7cfe7c30a6177
Reviewed-by: Lorn Potter <[email protected]>
Reviewed-by: Morten Johan Sørvig <[email protected]>
| -rw-r--r-- | src/plugins/platforms/wasm/qwasminputcontext.cpp | 18 | 
1 files changed, 8 insertions, 10 deletions
diff --git a/src/plugins/platforms/wasm/qwasminputcontext.cpp b/src/plugins/platforms/wasm/qwasminputcontext.cpp index 16c1e5ad1ec..191e2947629 100644 --- a/src/plugins/platforms/wasm/qwasminputcontext.cpp +++ b/src/plugins/platforms/wasm/qwasminputcontext.cpp @@ -276,7 +276,15 @@ void QWasmInputContext::updateInputElement()      m_inputElement.set("selectionStart", queryEvent.value(Qt::ImAnchorPosition).toUInt());      m_inputElement.set("selectionEnd", queryEvent.value(Qt::ImCursorPosition).toUInt()); +    QInputMethodQueryEvent query((Qt::InputMethodQueries(Qt::ImHints))); +    QCoreApplication::sendEvent(m_focusObject, &query); +    if (Qt::InputMethodHints(query.value(Qt::ImHints).toInt()).testFlag(Qt::ImhHiddenText)) +        m_inputElement.set("type", "password"); +    else +        m_inputElement.set("type", "text"); +      m_inputElement.set("inputMode", std::string("text")); +      m_inputElement.call<void>("focus");  } @@ -284,16 +292,6 @@ void QWasmInputContext::setFocusObject(QObject *object)  {      qCDebug(qLcQpaWasmInputContext) << Q_FUNC_INFO << object << inputMethodAccepted(); -    QInputMethodQueryEvent query(Qt::InputMethodQueries(Qt::ImEnabled | Qt::ImHints)); -    QCoreApplication::sendEvent(object, &query); -    if (query.value(Qt::ImEnabled).toBool() -        && Qt::InputMethodHints(query.value(Qt::ImHints).toInt()).testFlag(Qt::ImhHiddenText)) { -        m_inputElement.set("type", "password"); -    } else { -        if (m_inputElement["type"].as<std::string>() != std::string("text")) -            m_inputElement.set("type", "text"); -    } -      // Commit the previous composition before change m_focusObject      if (m_focusObject && !m_preeditString.isEmpty())          commitPreeditAndClear();  | 
