summaryrefslogtreecommitdiff
path: root/src/gui/widgets
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
parent38474d0c3c14cf595aed61ee1e4a69d48abbcf92 (diff)
downloadmana-client-627e1271f0ac2e7bd95a83f521ecbcf1b554ba80.tar.gz
mana-client-627e1271f0ac2e7bd95a83f521ecbcf1b554ba80.tar.bz2
mana-client-627e1271f0ac2e7bd95a83f521ecbcf1b554ba80.tar.xz
mana-client-627e1271f0ac2e7bd95a83f521ecbcf1b554ba80.zip
Adding autoComplete for invite
Signed-off-by: Jared Adams <jaxad0127@gmail.com>
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/shoplistbox.h2
-rw-r--r--src/gui/widgets/textfield.cpp16
-rw-r--r--src/gui/widgets/textfield.h11
3 files changed, 27 insertions, 2 deletions
diff --git a/src/gui/widgets/shoplistbox.h b/src/gui/widgets/shoplistbox.h
index 9232a5a4..087bdd53 100644
--- a/src/gui/widgets/shoplistbox.h
+++ b/src/gui/widgets/shoplistbox.h
@@ -48,7 +48,7 @@ class ShopListBox : public ListBox
ShopListBox(gcn::ListModel *listModel, ShopItems *shopListModel);
/**
- * Deconstructor
+ * Destructor
*/
~ShopListBox();
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;
diff --git a/src/gui/widgets/textfield.h b/src/gui/widgets/textfield.h
index 58e37f5c..1e6df9d6 100644
--- a/src/gui/widgets/textfield.h
+++ b/src/gui/widgets/textfield.h
@@ -90,6 +90,16 @@ class TextField : public gcn::TextField
*/
int getValue() const;
+ /**
+ * Set if the tabulator key causes auto complete
+ */
+ void setAutoComplete(bool b ) {mAutoComplete = b;}
+
+ /**
+ * Returns if the tabulator key causes auto complete
+ */
+ bool getAutoComplete() {return mAutoComplete;}
+
private:
void handlePaste();
@@ -100,6 +110,7 @@ class TextField : public gcn::TextField
int mMinimum;
int mMaximum;
bool mLoseFocusOnTab;
+ bool mAutoComplete;
};
#endif