From 5d9f22a757b95f9cefb5ee8244ac5a4474c1f299 Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Tue, 17 Apr 2018 21:28:15 +0200 Subject: [PATCH] When deleting a focus scope the hasFocus() flag is not cleared for the item having the local scope. In situations, where the focusScope is no parent ( only a parentItem() ) and the focusItem gets reparented we run into an invalid situation with a wron focus flag. To work around this Qt bug we manually clear the focus flag. --- inputcontext/QskInputContext.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/inputcontext/QskInputContext.cpp b/inputcontext/QskInputContext.cpp index fb5e3c53..8f952a4a 100644 --- a/inputcontext/QskInputContext.cpp +++ b/inputcontext/QskInputContext.cpp @@ -355,6 +355,11 @@ void QskInputContext::showInputPanel() update( Qt::ImQueryAll ); inputPanel->setVisible( true ); +#if 0 + if ( auto focusItem = inputPanel->nextItemInFocusChain( true ) ) + qskForceActiveFocus( focusItem, Qt::OtherFocusReason ); +#endif + connect( inputPanel->window(), &QskWindow::visibleChanged, this, &QskInputContext::emitInputPanelVisibleChanged ); } @@ -375,7 +380,23 @@ void QskInputContext::hideInputPanel() else { if ( m_data->inputPopup ) + { +#if 1 + if ( auto focusItem = m_data->inputPopup->scopedFocusItem() ) + { + /* + Qt bug: QQuickItem::hasFocus() is not cleared + when the corresponding focusScope gets deleted. + Usually no problem, but here the focusItem is no + child and will be reused with a different parent + later. + */ + focusItem->setFocus( false ); + } +#endif + m_data->inputPopup->deleteLater(); + } } QskWindow* window = m_data->inputWindow;