From 270d6d2753473955a2b691a934eb2e550d13ebc3 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 23 Aug 2013 19:12:36 +0300 Subject: fix gui text input in SDL2. copy/paste broken for SDL2. --- src/gui/widgets/textfield.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/gui/widgets') 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)->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)->getActionId(); switch (action) -- cgit v1.2.3-70-g09d2