Skip to content

Commit

Permalink
Fix Enter key in TimeSpinBox going to MainWindow::keyPressEvent.
Browse files Browse the repository at this point in the history
  • Loading branch information
ddennedy committed Feb 6, 2015
1 parent d6edd53 commit 7105ca0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/widgets/timespinbox.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012 Meltytech, LLC
* Copyright (c) 2012-2015 Meltytech, LLC
* Author: Dan Dennedy <dan@dennedy.org>
*
* This program is free software: you can redistribute it and/or modify
Expand All @@ -19,6 +19,7 @@
#include "timespinbox.h"
#include "mltcontroller.h"
#include <QRegExpValidator>
#include <QKeyEvent>

TimeSpinBox::TimeSpinBox(QWidget *parent)
: QSpinBox(parent)
Expand Down Expand Up @@ -52,6 +53,14 @@ QString TimeSpinBox::textFromValue(int val) const
return QString();
}

void TimeSpinBox::keyPressEvent(QKeyEvent* event)
{
if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return)
clearFocus();
else
QSpinBox::keyPressEvent(event);
}


TimeSpinBoxLineEdit::TimeSpinBoxLineEdit(QWidget *parent)
: QLineEdit(parent)
Expand Down
1 change: 1 addition & 0 deletions src/widgets/timespinbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class TimeSpinBox : public QSpinBox
QValidator::State validate(QString &input, int &pos) const;
int valueFromText(const QString &text) const;
QString textFromValue(int val) const;
void keyPressEvent(QKeyEvent *event);

private:
QRegExpValidator* m_validator;
Expand Down

0 comments on commit 7105ca0

Please sign in to comment.