summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gui/npcintegerdialog.cpp16
-rw-r--r--src/gui/npcintegerdialog.h14
-rw-r--r--src/gui/npcstringdialog.cpp6
-rw-r--r--src/gui/npcstringdialog.h6
-rw-r--r--src/net/npchandler.cpp2
5 files changed, 36 insertions, 8 deletions
diff --git a/src/gui/npcintegerdialog.cpp b/src/gui/npcintegerdialog.cpp
index 4444e04b..c58fc460 100644
--- a/src/gui/npcintegerdialog.cpp
+++ b/src/gui/npcintegerdialog.cpp
@@ -32,9 +32,10 @@
NpcIntegerDialog::NpcIntegerDialog():
Window(_("NPC Number Request"))
{
+ mValueField = new IntTextField();
+
mDecButton = new Button("-", "decvalue", this);
mIncButton = new Button("+", "incvalue", this);
- mValueField = new IntTextField();
okButton = new Button(_("OK"), "ok", this);
cancelButton = new Button(_("Cancel"), "cancel", this);
resetButton = new Button(_("Reset"), "reset", this);
@@ -56,9 +57,6 @@ NpcIntegerDialog::NpcIntegerDialog():
reflowLayout(175, 0);
setLocationRelativeTo(getParent());
-
- mValueField->setActionEventId("valuefield");
- mValueField->addKeyListener(this);
}
void NpcIntegerDialog::setRange(const int min, const int max)
@@ -105,3 +103,13 @@ void NpcIntegerDialog::action(const gcn::ActionEvent &event)
mValueField->reset();
}
}
+
+bool NpcIntegerDialog::isInputFocused()
+{
+ return mValueField->isFocused();
+}
+
+void NpcIntegerDialog::requestFocus()
+{
+ mValueField->requestFocus();
+}
diff --git a/src/gui/npcintegerdialog.h b/src/gui/npcintegerdialog.h
index b9ce70be..10ec60b9 100644
--- a/src/gui/npcintegerdialog.h
+++ b/src/gui/npcintegerdialog.h
@@ -23,7 +23,6 @@
#define GUI_NPCINTEGERDIALOG_H
#include <guichan/actionlistener.hpp>
-#include <guichan/keylistener.hpp>
#include "window.h"
@@ -34,8 +33,7 @@ class IntTextField;
*
* \ingroup Interface
*/
-class NpcIntegerDialog : public Window, public gcn::ActionListener,
- public gcn::KeyListener
+class NpcIntegerDialog : public Window, public gcn::ActionListener
{
public:
/**
@@ -63,6 +61,16 @@ class NpcIntegerDialog : public Window, public gcn::ActionListener,
*/
void setRange(const int min, const int max);
+ /**
+ * Checks whether NpcStringDialog is Focused or not.
+ */
+ bool isInputFocused();
+
+ /**
+ * Requests the textfield to take focus for input.
+ */
+ void requestFocus();
+
private:
gcn::Button *mDecButton;
gcn::Button *mIncButton;
diff --git a/src/gui/npcstringdialog.cpp b/src/gui/npcstringdialog.cpp
index 468326d6..718c416f 100644
--- a/src/gui/npcstringdialog.cpp
+++ b/src/gui/npcstringdialog.cpp
@@ -33,6 +33,7 @@ NpcStringDialog::NpcStringDialog():
Window(_("NPC Text Request"))
{
mValueField = new TextField("");
+
okButton = new Button(_("OK"), "ok", this);
cancelButton = new Button(_("Cancel"), "cancel", this);
@@ -71,3 +72,8 @@ bool NpcStringDialog::isInputFocused()
{
return mValueField->isFocused();
}
+
+void NpcStringDialog::requestFocus()
+{
+ mValueField->requestFocus();
+}
diff --git a/src/gui/npcstringdialog.h b/src/gui/npcstringdialog.h
index aa39764d..1933e0f1 100644
--- a/src/gui/npcstringdialog.h
+++ b/src/gui/npcstringdialog.h
@@ -23,7 +23,6 @@
#define GUI_NPCSTRINGDIALOG_H
#include <guichan/actionlistener.hpp>
-#include <guichan/keylistener.hpp>
#include "window.h"
@@ -64,6 +63,11 @@ class NpcStringDialog : public Window, public gcn::ActionListener
*/
bool isInputFocused();
+ /**
+ * Requests the textfield to take focus for input.
+ */
+ void requestFocus();
+
private:
gcn::TextField *mValueField;
gcn::Button *okButton;
diff --git a/src/net/npchandler.cpp b/src/net/npchandler.cpp
index 82b07d41..4e17a27e 100644
--- a/src/net/npchandler.cpp
+++ b/src/net/npchandler.cpp
@@ -92,6 +92,7 @@ void NPCHandler::handleMessage(MessageIn *msg)
current_npc = dynamic_cast<NPC*>(beingManager->findBeing(id));
npcIntegerDialog->setRange(0, 2147483647);
npcIntegerDialog->setVisible(true);
+ npcIntegerDialog->requestFocus();
break;
case SMSG_NPC_STR_INPUT:
@@ -100,6 +101,7 @@ void NPCHandler::handleMessage(MessageIn *msg)
current_npc = dynamic_cast<NPC*>(beingManager->findBeing(id));
npcStringDialog->setValue("");
npcStringDialog->setVisible(true);
+ npcStringDialog->requestFocus();
break;
}
}