diff options
Diffstat (limited to 'src/gui/inttextbox.cpp')
-rw-r--r-- | src/gui/inttextbox.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/gui/inttextbox.cpp b/src/gui/inttextbox.cpp index 4825fbf5..a995f084 100644 --- a/src/gui/inttextbox.cpp +++ b/src/gui/inttextbox.cpp @@ -21,7 +21,7 @@ #include "inttextbox.h" -#include <guichan/key.hpp> +#include "sdlinput.h" #include "../utils/tostring.h" @@ -35,17 +35,20 @@ IntTextBox::keyPressed(gcn::KeyEvent &event) { const gcn::Key &key = event.getKey(); - if (key.isNumber() || key.getValue() == gcn::Key::BACKSPACE - || key.getValue() == gcn::Key::DELETE) + if (key.getValue() == Key::BACKSPACE || + key.getValue() == Key::DELETE) { - gcn::TextBox::keyPressed(event); + setText(std::string()); + event.consume(); } - std::stringstream s(gcn::TextBox::getText()); + if (!key.isNumber()) return; + TextField::keyPressed(event); + + std::istringstream s(getText()); int i; s >> i; - if (gcn::TextBox::getText() != "") - setInt(i); + setInt(i); } void IntTextBox::setRange(int min, int max) @@ -56,9 +59,7 @@ void IntTextBox::setRange(int min, int max) int IntTextBox::getInt() { - if (gcn::TextBox::getText() == "") - return 0; - return mValue; + return getText().empty() ? mMin : mValue; } void IntTextBox::setInt(int i) |