summaryrefslogtreecommitdiff
path: root/src/gui/widgets/textfield.cpp
diff options
context:
space:
mode:
authorStefan Dombrowski <stefan@uni-bonn.de>2010-08-25 20:38:06 +0200
committerJared Adams <jaxad0127@gmail.com>2010-08-25 12:59:25 -0600
commit627e1271f0ac2e7bd95a83f521ecbcf1b554ba80 (patch)
tree5071591268bdfa40add8a07b859fb1bf4d123db4 /src/gui/widgets/textfield.cpp
parent38474d0c3c14cf595aed61ee1e4a69d48abbcf92 (diff)
downloadmana-627e1271f0ac2e7bd95a83f521ecbcf1b554ba80.tar.gz
mana-627e1271f0ac2e7bd95a83f521ecbcf1b554ba80.tar.bz2
mana-627e1271f0ac2e7bd95a83f521ecbcf1b554ba80.tar.xz
mana-627e1271f0ac2e7bd95a83f521ecbcf1b554ba80.zip
Adding autoComplete for invite
Signed-off-by: Jared Adams <jaxad0127@gmail.com>
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 4453f522..60a1f57f 100644
--- a/src/gui/widgets/textfield.cpp
+++ b/src/gui/widgets/textfield.cpp
@@ -21,9 +21,11 @@
#include "gui/widgets/textfield.h"
+#include "beingmanager.h"
#include "configuration.h"
#include "graphics.h"
+#include "gui/chat.h"
#include "gui/palette.h"
#include "gui/sdlinput.h"
#include "gui/theme.h"
@@ -43,7 +45,8 @@ ImageRect TextField::skin;
TextField::TextField(const std::string &text, bool loseFocusOnTab):
gcn::TextField(text),
- mNumeric(false)
+ mNumeric(false),
+ mAutoComplete(false)
{
setFrameSize(2);
@@ -246,6 +249,17 @@ void TextField::keyPressed(gcn::KeyEvent &keyEvent)
break;
case Key::TAB:
+ if (mAutoComplete && mText.size() > 0)
+ {
+ std::vector<std::string> names;
+ beingManager->getPlayerNames(names, false);
+ std::string newName = chatWindow->autoComplete(names, mText);
+ if (newName != "")
+ {
+ setText(newName);
+ setCaretPosition(mText.size());
+ }
+ }
if (mLoseFocusOnTab)
return;
break;