diff options
author | Ira Rice <irarice@gmail.com> | 2009-02-04 22:13:12 -0700 |
---|---|---|
committer | Ira Rice <irarice@gmail.com> | 2009-02-04 22:13:12 -0700 |
commit | b0a8b8607962081e87716ab0dfbca2439953f420 (patch) | |
tree | 0cd03f7c948c5d5647351f78ed9b3a33628c8b72 /src | |
parent | 373f1aca8bb651332fec7031853d9a685ebc896e (diff) | |
download | mana-b0a8b8607962081e87716ab0dfbca2439953f420.tar.gz mana-b0a8b8607962081e87716ab0dfbca2439953f420.tar.bz2 mana-b0a8b8607962081e87716ab0dfbca2439953f420.tar.xz mana-b0a8b8607962081e87716ab0dfbca2439953f420.zip |
Modified the NPC string and integer classes to automatically take focus
to the input fields. Now the only NPC dialog which isn't completely
navigatable by the keyboard alone is the NPC list dialog (seems to
have regressed slightly recently).
Signed-off-by: Ira Rice <irarice@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/npcintegerdialog.cpp | 16 | ||||
-rw-r--r-- | src/gui/npcintegerdialog.h | 14 | ||||
-rw-r--r-- | src/gui/npcstringdialog.cpp | 6 | ||||
-rw-r--r-- | src/gui/npcstringdialog.h | 6 | ||||
-rw-r--r-- | src/net/npchandler.cpp | 2 |
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; } } |