summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-10-23 12:46:55 +0300
committerAndrei Karas <akaras@inbox.ru>2013-10-23 12:46:55 +0300
commit0dca3216743cd5deaffad45ca50fccd7280eb6bd (patch)
treebdb79a4ada8c4d80005f6d16138d39b9dacb95fc
parentc733ecf657fbe656b89a41d91fe0e0634312bf96 (diff)
downloadmv-0dca3216743cd5deaffad45ca50fccd7280eb6bd.tar.gz
mv-0dca3216743cd5deaffad45ca50fccd7280eb6bd.tar.bz2
mv-0dca3216743cd5deaffad45ca50fccd7280eb6bd.tar.xz
mv-0dca3216743cd5deaffad45ca50fccd7280eb6bd.zip
Fix inttextfield on SDL2.
This allow enter numbers for example in drop or split dialogs.
-rwxr-xr-xbuild/bmakedebug3
-rw-r--r--src/gui/widgets/inttextfield.cpp21
2 files changed, 23 insertions, 1 deletions
diff --git a/build/bmakedebug b/build/bmakedebug
index 5532a2b8a..ebe7bbc7e 100755
--- a/build/bmakedebug
+++ b/build/bmakedebug
@@ -46,7 +46,8 @@ autoreconf -i
--with-internalguichan=yes \
--enable-tcmalloc=no \
--enable-googleprofiler=no \
---enable-eathena=yes
+--enable-eathena=yes \
+--with-sdl2
cd po
make -j8 update-gmo 2>../build/make1.log
diff --git a/src/gui/widgets/inttextfield.cpp b/src/gui/widgets/inttextfield.cpp
index a56023dc5..521d26d59 100644
--- a/src/gui/widgets/inttextfield.cpp
+++ b/src/gui/widgets/inttextfield.cpp
@@ -22,6 +22,10 @@
#include "gui/widgets/inttextfield.h"
+#ifdef USE_SDL2
+#include "gui/sdlinput.h"
+#endif
+
#include "input/keydata.h"
#include "input/keyevent.h"
@@ -58,8 +62,25 @@ void IntTextField::keyPressed(gcn::KeyEvent &event)
event.consume();
}
+#ifdef USE_SDL2
+ const int val = event.getKey().getValue();
+ if (val != Key::TEXTINPUT)
+ return;
+
+ const std::string str = static_cast<KeyEvent*>(&event)->getText();
+ if (str.empty())
+ return;
+ const size_t sz = str.size();
+ for (size_t f = 0; f < sz; f ++)
+ {
+ const char chr = str[f];
+ if (chr < '0' || chr > '9')
+ return;
+ }
+#else
if (!event.getKey().isNumber())
return;
+#endif
TextField::keyPressed(event);