summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-11-14 10:07:55 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2009-01-10 01:15:34 +0100
commit469b6dfc1badbac467b9145d2eaaaa87238087d9 (patch)
tree48aefeb407ac224dacf896e474dc1d23d81b477c
parent04471a1d4a9575a81016de0375c2000d793a044d (diff)
downloadmana-469b6dfc1badbac467b9145d2eaaaa87238087d9.tar.gz
mana-469b6dfc1badbac467b9145d2eaaaa87238087d9.tar.bz2
mana-469b6dfc1badbac467b9145d2eaaaa87238087d9.tar.xz
mana-469b6dfc1badbac467b9145d2eaaaa87238087d9.zip
Improved item amount dialog box.
(cherry picked from commit 69c147510bce9aa24be5ddcb3d050a5d52e3abe7) Conflicts: src/gui/item_amount.cpp
-rw-r--r--src/gui/inttextbox.cpp21
-rw-r--r--src/gui/inttextbox.h4
2 files changed, 13 insertions, 12 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)
diff --git a/src/gui/inttextbox.h b/src/gui/inttextbox.h
index 8fc8e404..8dad0c39 100644
--- a/src/gui/inttextbox.h
+++ b/src/gui/inttextbox.h
@@ -22,12 +22,12 @@
#ifndef INTTEXTBOX_H
#define INTTEXTBOX_H
-#include "textbox.h"
+#include "textfield.h"
/**
* TextBox which only accepts numbers as input.
*/
-class IntTextBox : public TextBox
+class IntTextBox : public TextField
{
public:
/**