From fc48c24c6d366e165cbcfbd022d9421790089890 Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Sun, 6 Dec 2009 13:01:16 -0700 Subject: Improve keyboard accessibility of login sequence Enter and Escape now move forward and backwards for all dialogs except ServerSelectDialog (Escape quits) and CharSelectDialog (Enter doesn't do anything special). --- src/gui/serverdialog.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/gui/serverdialog.cpp') diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index 39c2792f..32e714c6 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -22,6 +22,7 @@ #include "gui/serverdialog.h" #include "gui/okdialog.h" +#include "gui/sdlinput.h" #include "gui/widgets/button.h" #include "gui/widgets/label.h" @@ -149,9 +150,10 @@ ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir): // Make sure the list has enough height getLayout().setRowHeight(3, 80); - reflowLayout(300, 0); + addKeyListener(this); + center(); setFieldsReadOnly(true); setVisible(true); @@ -248,6 +250,20 @@ void ServerDialog::action(const gcn::ActionEvent &event) } } +void ServerDialog::keyPressed(gcn::KeyEvent &keyEvent) +{ + gcn::Key key = keyEvent.getKey(); + + if (key.getValue() == Key::ESCAPE) + { + state = STATE_EXIT; + } + else if (key.getValue() == Key::ENTER) + { + action(gcn::ActionEvent(NULL, mConnectButton->getActionEventId())); + } +} + void ServerDialog::valueChanged(const gcn::SelectionEvent &event) { const int index = mServersList->getSelected(); -- cgit v1.2.3-70-g09d2