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/updatewindow.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/gui/updatewindow.cpp') diff --git a/src/gui/updatewindow.cpp b/src/gui/updatewindow.cpp index 801bd161..afb87430 100644 --- a/src/gui/updatewindow.cpp +++ b/src/gui/updatewindow.cpp @@ -28,6 +28,8 @@ #include "gui/widgets/progressbar.h" #include "gui/widgets/scrollarea.h" +#include "gui/sdlinput.h" + #include "configuration.h" #include "log.h" #include "main.h" @@ -105,6 +107,8 @@ UpdaterWindow::UpdaterWindow(const std::string &updateHost, Layout &layout = getLayout(); layout.setRowHeight(0, Layout::AUTO_SET); + addKeyListener(this); + center(); setVisible(true); mCancelButton->requestFocus(); @@ -162,6 +166,29 @@ void UpdaterWindow::action(const gcn::ActionEvent &event) } } +void UpdaterWindow::keyPressed(gcn::KeyEvent &keyEvent) +{ + gcn::Key key = keyEvent.getKey(); + + if (key.getValue() == Key::ESCAPE) + { + action(gcn::ActionEvent(NULL, mCancelButton->getActionEventId())); + state = STATE_WORLD_SELECT; + } + else if (key.getValue() == Key::ENTER) + { + if (mDownloadStatus == UPDATE_COMPLETE || + mDownloadStatus == UPDATE_ERROR) + { + action(gcn::ActionEvent(NULL, mPlayButton->getActionEventId())); + } + else + { + action(gcn::ActionEvent(NULL, mCancelButton->getActionEventId())); + } + } +} + void UpdaterWindow::loadNews() { if (!mMemoryBuffer) -- cgit v1.2.3-70-g09d2