aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2019-03-15 15:05:22 +0100
committerRichard Moe Gustavsen <richard.gustavsen@qt.io>2019-03-21 15:21:15 +0000
commit5a07a970fa9d73fc2c4da8966fadcb35d142c7f5 (patch)
tree11f90c8963947008ff8bd17742004e9c66021fe9
parent27e030f24b05dac56189c34951da38fd68dc64a1 (diff)
QQuickComboBox: ensure we don't close popup on iOS
On iOS (and Android), we give focus to a control on touch release (rather than on touch begin, which is normal on desktop). For a QQuickCombobox, this means that we will both handle focus and open the popup on touch release, and not focus on touch begin and open popup on touch release, like on desktop. Because of this, we need to be more careful about when we choose to close the popup as well, otherwise it will close down before it gets a chance to show on iOS. This patch will check why we lose focus on both the inner line edit and the combobox itself, and based on this, choose whether we should close the popup. Basically, if focus is just transferred between the popup button and the line edit, we choose to keep the popup open. Fixes: QTBUG-70161 Change-Id: Iec242c0b5570844868085480fdf96fc49d189b82 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r--src/quicktemplates2/qquickcombobox.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/quicktemplates2/qquickcombobox.cpp b/src/quicktemplates2/qquickcombobox.cpp
index ffdb7cc2..03dd6086 100644
--- a/src/quicktemplates2/qquickcombobox.cpp
+++ b/src/quicktemplates2/qquickcombobox.cpp
@@ -1556,8 +1556,13 @@ bool QQuickComboBox::eventFilter(QObject *object, QEvent *event)
break;
}
case QEvent::FocusOut:
- d->hidePopup(false);
- setPressed(false);
+ if (qGuiApp->focusObject() != this) {
+ // 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.
+ d->hidePopup(false);
+ setPressed(false);
+ }
break;
#if QT_CONFIG(im)
case QEvent::InputMethod:
@@ -1583,8 +1588,14 @@ void QQuickComboBox::focusOutEvent(QFocusEvent *event)
{
Q_D(QQuickComboBox);
QQuickControl::focusOutEvent(event);
- d->hidePopup(false);
- setPressed(false);
+
+ if (qGuiApp->focusObject() != d->contentItem) {
+ // Only close the popup if focus was transferred
+ // somewhere else than to the inner line edit (which is
+ // normally done from QQuickComboBox::focusInEvent).
+ d->hidePopup(false);
+ setPressed(false);
+ }
}
#if QT_CONFIG(im)