summaryrefslogtreecommitdiff
path: root/src/gui/register.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2007-03-24 13:05:27 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2007-03-24 13:05:27 +0000
commitb5a95c2e1151ce61a2615cffcbb6821c150f40fd (patch)
treedaca526b12ba0d9f761af3d65d033719ea50c8d3 /src/gui/register.cpp
parentd5e8513e085b6fc8da2ea4bb7151ac8e98be74c8 (diff)
downloadmana-b5a95c2e1151ce61a2615cffcbb6821c150f40fd.tar.gz
mana-b5a95c2e1151ce61a2615cffcbb6821c150f40fd.tar.bz2
mana-b5a95c2e1151ce61a2615cffcbb6821c150f40fd.tar.xz
mana-b5a95c2e1151ce61a2615cffcbb6821c150f40fd.zip
Make sure that when a network error occurs, the error message is available and
shown to the user. Also, only enable Register button when all necessary fields are filled in.
Diffstat (limited to 'src/gui/register.cpp')
-rw-r--r--src/gui/register.cpp25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/gui/register.cpp b/src/gui/register.cpp
index ad3a6388..b42a7af8 100644
--- a/src/gui/register.cpp
+++ b/src/gui/register.cpp
@@ -108,6 +108,11 @@ RegisterDialog::RegisterDialog(LoginData *loginData):
mCancelButton->getX() - mRegisterButton->getWidth() - 5,
height - mRegisterButton->getHeight() - 5);
+ mUserField->addKeyListener(this);
+ mPasswordField->addKeyListener(this);
+ mConfirmField->addKeyListener(this);
+ mServerField->addKeyListener(this);
+
/* TODO:
* This is a quick and dirty way to respond to the ENTER key, regardless of
* which text field is selected. There may be a better way now with the new
@@ -139,6 +144,8 @@ RegisterDialog::RegisterDialog(LoginData *loginData):
setVisible(true);
mUserField->requestFocus();
mUserField->setCaretPosition(mUserField->getText().length());
+
+ mRegisterButton->setEnabled(canSubmit());
}
RegisterDialog::~RegisterDialog()
@@ -153,7 +160,7 @@ RegisterDialog::action(const gcn::ActionEvent &event)
{
state = LOGIN_STATE;
}
- else if (event.getId() == "register")
+ else if (event.getId() == "register" && canSubmit())
{
const std::string user = mUserField->getText();
logger->log("RegisterDialog::register Username is %s", user.c_str());
@@ -235,3 +242,19 @@ RegisterDialog::action(const gcn::ActionEvent &event)
}
}
}
+
+void
+RegisterDialog::keyPressed(gcn::KeyEvent &keyEvent)
+{
+ mRegisterButton->setEnabled(canSubmit());
+}
+
+bool
+RegisterDialog::canSubmit()
+{
+ return !mUserField->getText().empty() &&
+ !mPasswordField->getText().empty() &&
+ !mConfirmField->getText().empty() &&
+ !mServerField->getText().empty() &&
+ state == REGISTER_STATE;
+}