diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-02-06 00:40:31 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-02-06 00:40:31 +0300 |
commit | 16bc04769d0fdd319be5bcebddb49ddd87f76d94 (patch) | |
tree | 8a6561182c450e06be0405ced31982b81ea629ca /src/gui/registerdialog.cpp | |
parent | d514c4c7bc62061935579505b497307f89fc8db5 (diff) | |
download | manaplus-16bc04769d0fdd319be5bcebddb49ddd87f76d94.tar.gz manaplus-16bc04769d0fdd319be5bcebddb49ddd87f76d94.tar.bz2 manaplus-16bc04769d0fdd319be5bcebddb49ddd87f76d94.tar.xz manaplus-16bc04769d0fdd319be5bcebddb49ddd87f76d94.zip |
Add support in register dialog for apply/close by keyboard
Default keys: enter and esc
Diffstat (limited to 'src/gui/registerdialog.cpp')
-rw-r--r-- | src/gui/registerdialog.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/gui/registerdialog.cpp b/src/gui/registerdialog.cpp index 40738abb2..d803bd89e 100644 --- a/src/gui/registerdialog.cpp +++ b/src/gui/registerdialog.cpp @@ -24,6 +24,8 @@ #include "client.h" #include "configuration.h" +#include "keydata.h" +#include "keyevent.h" #include "gui/logindialog.h" #include "gui/okdialog.h" @@ -270,7 +272,26 @@ void RegisterDialog::action(const gcn::ActionEvent &event) void RegisterDialog::keyPressed(gcn::KeyEvent &keyEvent A_UNUSED) { - mRegisterButton->setEnabled(canSubmit()); + if (keyEvent.isConsumed()) + { + mRegisterButton->setEnabled(canSubmit()); + return; + } + const int actionId = static_cast<KeyEvent*>( + &keyEvent)->getActionId(); + if (actionId == static_cast<int>(Input::KEY_GUI_CANCEL)) + { + action(gcn::ActionEvent(nullptr, mCancelButton->getActionEventId())); + } + else if (actionId == static_cast<int>(Input::KEY_GUI_SELECT) + || actionId == static_cast<int>(Input::KEY_GUI_SELECT2)) + { + action(gcn::ActionEvent(nullptr, mRegisterButton->getActionEventId())); + } + else + { + mRegisterButton->setEnabled(canSubmit()); + } } bool RegisterDialog::canSubmit() const |