diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/npcintegerdialog.cpp | 5 | ||||
-rw-r--r-- | src/gui/npcintegerdialog.h | 7 | ||||
-rw-r--r-- | src/gui/npcstringdialog.cpp | 3 | ||||
-rw-r--r-- | src/gui/npcstringdialog.h | 1 |
4 files changed, 15 insertions, 1 deletions
diff --git a/src/gui/npcintegerdialog.cpp b/src/gui/npcintegerdialog.cpp index b05e77ba..6b26349a 100644 --- a/src/gui/npcintegerdialog.cpp +++ b/src/gui/npcintegerdialog.cpp @@ -109,6 +109,11 @@ void NpcIntegerDialog::action(const gcn::ActionEvent &event) } } +void NpcIntegerDialog::setDefaultValue(const int value) +{ + mValueField->setDefaultValue(value); +} + bool NpcIntegerDialog::isInputFocused() { return mValueField->isFocused(); diff --git a/src/gui/npcintegerdialog.h b/src/gui/npcintegerdialog.h index a8ffcf0f..7c064ca6 100644 --- a/src/gui/npcintegerdialog.h +++ b/src/gui/npcintegerdialog.h @@ -62,6 +62,13 @@ class NpcIntegerDialog : public Window, public gcn::ActionListener void setRange(const int min, const int max); /** + * Sets the default value. + * + * @param value The new default value + */ + void setDefaultValue(const int value); + + /** * Checks whether NpcStringDialog is Focused or not. */ bool isInputFocused(); diff --git a/src/gui/npcstringdialog.cpp b/src/gui/npcstringdialog.cpp index dc5893f8..f2ccc3cf 100644 --- a/src/gui/npcstringdialog.cpp +++ b/src/gui/npcstringdialog.cpp @@ -57,13 +57,14 @@ std::string NpcStringDialog::getValue() void NpcStringDialog::setValue(const std::string &value) { mValueField->setText(value); + mDefault = value; } void NpcStringDialog::action(const gcn::ActionEvent &event) { if (event.getId() == "cancel") { - mValueField->setText(""); + mValueField->setText(mDefault); npcTextDialog->addText(_("\n> Cancel\n")); } else diff --git a/src/gui/npcstringdialog.h b/src/gui/npcstringdialog.h index 960f8cec..0faaf203 100644 --- a/src/gui/npcstringdialog.h +++ b/src/gui/npcstringdialog.h @@ -70,6 +70,7 @@ class NpcStringDialog : public Window, public gcn::ActionListener private: gcn::TextField *mValueField; + std::string mDefault; }; #endif // GUI_NPCSTRINGDIALOG_H |