Skip to content

Commit 81a4c80

Browse files
committed
FIXED: Could not type name in scores dialog
1 parent 1870336 commit 81a4c80

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/scores_dialog.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,9 +400,7 @@ void ScoresDialog::hideEvent(QHideEvent* event)
400400

401401
void 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

src/scores_dialog.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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;

0 commit comments

Comments
 (0)