summaryrefslogtreecommitdiff
path: root/src/gui/widgets/textfield.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-08-23 19:12:36 +0300
committerAndrei Karas <akaras@inbox.ru>2013-08-24 21:08:16 +0300
commit270d6d2753473955a2b691a934eb2e550d13ebc3 (patch)
tree2ba55bab0c21b1775bfcd85e80d24cbfbbe652e9 /src/gui/widgets/textfield.cpp
parentc7f5d0a71d7318ccc4c3f28ab90d688a1a0868b3 (diff)
downloadmanaverse-270d6d2753473955a2b691a934eb2e550d13ebc3.tar.gz
manaverse-270d6d2753473955a2b691a934eb2e550d13ebc3.tar.bz2
manaverse-270d6d2753473955a2b691a934eb2e550d13ebc3.tar.xz
manaverse-270d6d2753473955a2b691a934eb2e550d13ebc3.zip
fix gui text input in SDL2.
copy/paste broken for SDL2.
Diffstat (limited to 'src/gui/widgets/textfield.cpp')
-rw-r--r--src/gui/widgets/textfield.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp
index bc2d9c946..0fec552e3 100644
--- a/src/gui/widgets/textfield.cpp
+++ b/src/gui/widgets/textfield.cpp
@@ -195,7 +195,20 @@ int TextField::getValue() const
void TextField::keyPressed(gcn::KeyEvent &keyEvent)
{
const int val = keyEvent.getKey().getValue();
-
+#ifdef USE_SDL2
+ if (val == Key::TEXTINPUT)
+ {
+ std::string str = static_cast<KeyEvent*>(&keyEvent)->getText();
+ mText.insert(mCaretPosition, str);
+ mCaretPosition += str.size();
+ keyEvent.consume();
+ fixScroll();
+ if (mSendAlwaysEvents)
+ distributeActionEvent();
+ return;
+ }
+ bool consumed(false);
+#else
if (val >= 32)
{
if (mNumeric)
@@ -366,6 +379,7 @@ void TextField::keyPressed(gcn::KeyEvent &keyEvent)
fixScroll();
return;
}
+#endif
const int action = static_cast<KeyEvent*>(&keyEvent)->getActionId();
switch (action)