From fdece5a40729d7c370d920ddfcad2921183dbbec Mon Sep 17 00:00:00 2001 From: Bartlomiej Moskal Date: Thu, 21 Jan 2021 09:52:45 +0100 Subject: ComboBox: don't focus TextField when clicking on indicator Remove focusing editText for Combobox when clicking on indicator (when editable is set to true). Focus on Edit Text should be set only intentionally by user. Before this change, when focus was set on Combobox, it automatically set focus on editText. It was also happening when drop down indicator was clicked. Because of that, on some platform (like Android) virtual keyboard was appearing in case when it shouldn't be shown. Fixes: QTBUG-61021 Pick-to: 5.15 6.0 Change-Id: I813dcc3099c919ec32f0683e7e60e6082c5bc389 Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickcombobox.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/quicktemplates2') diff --git a/src/quicktemplates2/qquickcombobox.cpp b/src/quicktemplates2/qquickcombobox.cpp index c01d6394..c12ea962 100644 --- a/src/quicktemplates2/qquickcombobox.cpp +++ b/src/quicktemplates2/qquickcombobox.cpp @@ -1905,7 +1905,11 @@ void QQuickComboBox::focusInEvent(QFocusEvent *event) { Q_D(QQuickComboBox); QQuickControl::focusInEvent(event); - if (d->contentItem && isEditable()) + // Setting focus on TextField should not be done when drop down indicator was clicked + // That is why, if focus is not set with key reason, it should not be passed to textEdit by default. + // Focus on Edit Text should be set only intentionally by user. + if ((event->reason() == Qt::TabFocusReason || event->reason() == Qt::BacktabFocusReason || + event->reason() == Qt::ShortcutFocusReason) && d->contentItem && isEditable()) d->contentItem->forceActiveFocus(event->reason()); } -- cgit v1.2.3