File tree Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -400,9 +400,7 @@ void ScoresDialog::hideEvent(QHideEvent* event)
400400
401401void ScoresDialog::keyPressEvent (QKeyEvent* event)
402402{
403- if (!m_buttons->button (QDialogButtonBox::Close)->isDefault ()) {
404- m_buttons->button (QDialogButtonBox::Close)->setDefault (true );
405- m_buttons->button (QDialogButtonBox::Close)->setFocus ();
403+ if ((event->key () == Qt::Key_Enter) || (event->key () == Qt::Key_Return)) {
406404 event->ignore ();
407405 return ;
408406 }
@@ -416,6 +414,9 @@ void ScoresDialog::editingFinished()
416414 if (m_active_page) {
417415 m_active_page->editFinish (m_username);
418416 m_active_page = nullptr ;
417+
418+ m_buttons->button (QDialogButtonBox::Close)->setDefault (true );
419+ m_buttons->button (QDialogButtonBox::Close)->setFocus ();
419420 }
420421}
421422
Original file line number Diff line number Diff line change @@ -169,8 +169,8 @@ class ScoresDialog : public QDialog
169169 void hideEvent (QHideEvent* event) override ;
170170
171171 /* *
172- * Override keyPressEvent to focus the close button; dialog only recieves these events if the
173- * line edit is not focused .
172+ * Override keyPressEvent to ignore return key. Keeps dialog from closing when the player
173+ * presses return after entering their name .
174174 * @param event details of the key press event
175175 */
176176 void keyPressEvent (QKeyEvent* event) override ;
You can’t perform that action at this time.
0 commit comments