QKeySequenceEdit: don't finish when opening a context menu

Right-clicking in a QKeySequenceEdit opens the usual context menu for a
line edit, which generates a focusOut event. QKeySequenceEdit finishes
the recording when it loses focus, which includes deselecting the text.

We should not finish or deselect if the focusOut event has focusReason
FocusReasonPopup, as otherwise users cannot copy the text (keyboard
shortcuts don't work for that, obviously).

Pick-to: 6.6
Task-number: QTBUG-114624
Change-Id: I0b3c535c189151daa29cf17640493f3353e6394b
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
This commit is contained in:
Volker Hilsheimer 2023-06-19 12:44:37 +02:00
parent b992aabd89
commit 89566bf749

View File

@ -414,7 +414,8 @@ void QKeySequenceEdit::timerEvent(QTimerEvent *e)
void QKeySequenceEdit::focusOutEvent(QFocusEvent *e)
{
Q_D(QKeySequenceEdit);
d->finishEditing();
if (e->reason() != Qt::PopupFocusReason)
d->finishEditing();
QWidget::focusOutEvent(e);
}