diff --git a/Forms/Controls/TextBox.cpp b/Forms/Controls/TextBox.cpp index 079343c..eb08409 100644 --- a/Forms/Controls/TextBox.cpp +++ b/Forms/Controls/TextBox.cpp @@ -22,6 +22,7 @@ TextBox::TextBox(QWidget *parent) : QLineEdit(parent) { + connect(this, &TextBox::textChanged, this, &TextBox::onTextChanged); connect(this, &TextBox::editingFinished, this, &TextBox::onEditFinished); setup = false; } @@ -91,12 +92,24 @@ u32 TextBox::getUInt() return this->text().toUInt(nullptr, base); } -void TextBox::onEditFinished() +void TextBox::onTextChanged(QString string) { if (setup) { - QString string = this->text().toUpper(); + string = string.toUpper(); string.remove(filter); + + int position = this->cursorPosition(); + this->setText(string); + this->setCursorPosition(position); + } +} + +void TextBox::onEditFinished() +{ + if (setup) + { + QString string = this->text(); u64 temp = string.toULongLong(nullptr, base); if (temp > maxValue) @@ -108,8 +121,6 @@ void TextBox::onEditFinished() string = QString::number(minValue, base); } - int position = cursorPosition(); - setText(string); - setCursorPosition(position); + this->setText(string); } } diff --git a/Forms/Controls/TextBox.hpp b/Forms/Controls/TextBox.hpp index 3ccb6c7..80d1656 100644 --- a/Forms/Controls/TextBox.hpp +++ b/Forms/Controls/TextBox.hpp @@ -46,12 +46,13 @@ class TextBox : public QLineEdit private: bool setup; - u64 maxValue = 0; + u64 maxValue; u64 minValue; int base; QRegExp filter; private slots: + void onTextChanged(QString string); void onEditFinished(); };