Skip to content

Commit 525d866

Browse files
Fixed BUG #14953. Properly handle Esc key in Search box.
To fix BUG #14953, we properly handle Esc key in the Search box. pqSearchBox now eats the Esc key if the Esc key will clear the text in the Search box and passes it only if the text box is already empty. Passing it through will cause the parent widget to do its default thing, e.g. closing of dialogs. As a result the Settings dialog now behaves as follows: when there is some text in the Search box, hitting Esc will clear it. If you hit Esc again (or when the Search box) is empty, the dialog does it's default thing, i.e it closes. Change-Id: I4b3c47f8056cf5f0311a9e96bda6a0c91173bb5d
1 parent 71439c9 commit 525d866

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

Qt/Components/pqSearchBox.cxx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,17 @@ pqSearchBox::~pqSearchBox()
9393
//-----------------------------------------------------------------------------
9494
void pqSearchBox::keyPressEvent(QKeyEvent* keyEvent)
9595
{
96-
this->Superclass::keyPressEvent(keyEvent);
97-
9896
// Remove the current text in the line edit on escape pressed
99-
if (keyEvent && keyEvent->key() == Qt::Key_Escape)
97+
if (keyEvent &&
98+
keyEvent->key() == Qt::Key_Escape &&
99+
!this->Internals->SearchLineEdit->text().isEmpty())
100100
{
101101
this->Internals->SearchLineEdit->clear();
102102
}
103+
else
104+
{
105+
this->Superclass::keyPressEvent(keyEvent);
106+
}
103107
}
104108

105109
//-----------------------------------------------------------------------------

0 commit comments

Comments
 (0)