Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
5.15.0
Description
How to reproduce
1) Launch the provided qml snippet
2) Before the window shows up make it loose focus by clicking somewhere else. For example click the window search bar
3) After that make the Qt application regain focus by clicking the text box
4) The Keyboard is broken
Since a video value more than 1000 words look at the attached video
Analysis
I've done my homework and basically debug a little bit the Qt internals and that's what i discovered so far
- The bug is mainly caused by the Window visibility toggling from Windowed -> Hidden -> Windowed
- The virtual keyboard does not input any key because the input engine has no input method. Infact i usually get a 'Input method is not set' when this error occurs.
- The Input method is not set because the function "updateInputMethod()" in virtual keyboard "Keyboard.qml" is not called
- The "updateInputMethod()" is not called because the handler "onFucusChanged" of the Connection of the InputContext.priv is not called in "Keyboard.qml"
Connections { target: InputContext. function onFocusChanged() { if (InputContext.priv.focus) updateInputMethod() }
- By debugging i discovered that the InputContext.priv.focus should be toggled in "PlatformInputContext::update"
void PlatformInputContext::update(Qt::InputMethodQueries queries) { VIRTUALKEYBOARD_DEBUG() << "PlatformInputContext::update():" << queries; bool enabled = inputMethodQuery(Qt::ImEnabled).toBool(); #ifdef QT_VIRTUALKEYBOARD_DESKTOP if (enabled && !m_inputPanel && !m_desktopModeDisabled) { m_inputPanel = new DesktopInputPanel(this); m_inputPanel->createView(); if (m_inputContext) { m_selectionControl = new DesktopInputSelectionControl(this, m_inputContext); m_selectionControl->createHandles(); } } #endif if (m_inputContext) { if (enabled) { m_inputContext->priv()->update(queries); if (m_visible) updateInputPanelVisible(); } else { hideInputPanel(); } m_inputContext->priv()->setFocus(enabled); } }
- The PlatformInputContext is usually called when the Window gets focus. But this does not happen
Maybe this bug is related to QTBUG-86190 and in particular its patch set https://codereview.qt-project.org/c/qt/qtvirtualkeyboard/+/316091 changed the line
bool enabled = inputMethodQuery(Qt::ImEnabled).toBool();
to
bool enabled = inputMethodAccepted();
Attachments
Issue Links
- relates to
-
QTBUG-86190 Shift button on virtual keyboard is disabled on startup of application
- Closed