From bd126fdea95ed994fdd35d50e445b45af75657ab Mon Sep 17 00:00:00 2001 From: Alberto Mardegan Date: Sun, 24 Mar 2019 22:54:31 +0300 Subject: QQuickComboBox: don't hide popup if focused The ComboBox popup should be closed when the ComboBox loses focus, but not if the control gaining focus is the popup itself. While all the styles implemented in this module implement the ComboBox popup as an unfocusable window and handle all the keyboard events in QQuickComboBox itself, the developer can choose to replace the popup with a custom implementation, which might need the keyboard focus. Fixes: QTBUG-74661 Change-Id: I838ab9cb697df63ea2099e68f1ae99eadb06be08 Reviewed-by: Richard Moe Gustavsen --- src/quicktemplates2/qquickcombobox.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/quicktemplates2/qquickcombobox.cpp') diff --git a/src/quicktemplates2/qquickcombobox.cpp b/src/quicktemplates2/qquickcombobox.cpp index 03dd6086..328797b8 100644 --- a/src/quicktemplates2/qquickcombobox.cpp +++ b/src/quicktemplates2/qquickcombobox.cpp @@ -1556,10 +1556,10 @@ bool QQuickComboBox::eventFilter(QObject *object, QEvent *event) break; } case QEvent::FocusOut: - if (qGuiApp->focusObject() != this) { + if (qGuiApp->focusObject() != this && (!d->popup || !d->popup->hasActiveFocus())) { // Only close the popup if focus was transferred somewhere else - // than to the popup button (which normally means that the user - // clicked on the popup button to open it, not close it. + // than to the popup or the popup button (which normally means that + // the user clicked on the popup button to open it, not close it). d->hidePopup(false); setPressed(false); } @@ -1589,9 +1589,9 @@ void QQuickComboBox::focusOutEvent(QFocusEvent *event) Q_D(QQuickComboBox); QQuickControl::focusOutEvent(event); - if (qGuiApp->focusObject() != d->contentItem) { + if (qGuiApp->focusObject() != d->contentItem && (!d->popup || !d->popup->hasActiveFocus())) { // Only close the popup if focus was transferred - // somewhere else than to the inner line edit (which is + // somewhere else than to the popup or the inner line edit (which is // normally done from QQuickComboBox::focusInEvent). d->hidePopup(false); setPressed(false); -- cgit v1.2.3