aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquicktextinput
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2021-11-29 20:30:53 +0100
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2021-12-04 22:13:57 +0100
commit42d411e2e80c434f3e62cc55e32da2eeaa6149ae (patch)
tree1e0689ba7091b3c32cd16fb0eeed39ee5f8a4612 /tests/auto/quick/qquicktextinput
parent61ee61d8c977ecf876ce1d364cff634467b562a9 (diff)
Set PopupFocusReason when focus moves because a popup opens or closes
When a popup opens and takes keyboard focus, then the control that had focus needs to get a focusOut event, with the reason set correctly. This allows text controls to stop blinking, but not deselecting text. So set the reason parameter to Qt::PopupFocusReason in all calls to functions that change focus in response to a QQuickPopup showing or hiding. However, QQuickItem partially ignored focus changes where the reason was set to Qt::PopupFocusReason. This seems to be a left-over from a fix for issues with Qt Quick Control 1 made in c860d33437c59a35d9d17ad199ce4f0f to make sure that menu entries are enabled and selection is not removed. The reason given here is no longer relevant: of course popups need to take focus, otherwise we can't navigate menus with the keyboard; and they do, at the latest the MenuItem takes focus away from the control breaking the entire assumption. And since prior to this change no code other than the outdated tst_qquicktextinput test passed focus with Qt::PopupFocusReason, we can safely assume that this logic is no longer needed. Controls that want to ignore a focusOut with PopupFocusReason can do so with this change. Note: PopupFocusReason in Qt Quick means any popup, including dialogs, while in QtWidgets it means a Qt::Popup type window. Since Quick dialogs don't trigger window activation changes and focusOut events with corresponding focus reasons, and since QtQuick has no concept equivalent to Qt::Popup where this could become confusing, this seems acceptable. Fixes: QTBUG-71723 Task-number: QTBUG-75862 Task-number: QTBUG-36332 Pick-to: 6.2 Change-Id: I7a0a29830d8f7ed80b22411785214758b896562c Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'tests/auto/quick/qquicktextinput')
-rw-r--r--tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp2
1 files changed, 0 insertions, 2 deletions
diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
index 5e47476869..669f94ed48 100644
--- a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
+++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
@@ -3756,8 +3756,6 @@ void tst_qquicktextinput::focusOutNotClearSelection()
input.setFocus(false, Qt::PopupFocusReason);
QGuiApplication::processEvents();
QTRY_COMPARE(input.selectedText(), QLatin1String("llo"));
- // QTBUG-36332 and 36292: a popup window does not take focus
- QTRY_COMPARE(input.hasActiveFocus(), true);
input.setFocus(true);
QTRY_COMPARE(input.hasActiveFocus(), true);