summaryrefslogtreecommitdiff
path: root/src/gui/inttextbox.cpp
diff options
context:
space:
mode:
authorGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-11-14 10:07:55 +0000
committerGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-11-14 10:07:55 +0000
commit69c147510bce9aa24be5ddcb3d050a5d52e3abe7 (patch)
tree99e7ae22cf75ed210e26e77137bf37d67353839e /src/gui/inttextbox.cpp
parentcb04d148c9aed572fe6e66313100e2cd9b66f5d5 (diff)
downloadmana-69c147510bce9aa24be5ddcb3d050a5d52e3abe7.tar.gz
mana-69c147510bce9aa24be5ddcb3d050a5d52e3abe7.tar.bz2
mana-69c147510bce9aa24be5ddcb3d050a5d52e3abe7.tar.xz
mana-69c147510bce9aa24be5ddcb3d050a5d52e3abe7.zip
Improved item amount dialog box.
Diffstat (limited to 'src/gui/inttextbox.cpp')
-rw-r--r--src/gui/inttextbox.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/gui/inttextbox.cpp b/src/gui/inttextbox.cpp
index 2a09f255..5ae3dd93 100644
--- a/src/gui/inttextbox.cpp
+++ b/src/gui/inttextbox.cpp
@@ -23,7 +23,7 @@
#include "inttextbox.h"
-#include <guichan/key.hpp>
+#include "sdlinput.h"
#include "../utils/tostring.h"
@@ -37,17 +37,21 @@ 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);
+ generateAction();
}
void IntTextBox::setRange(int min, int max)
@@ -58,9 +62,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)