From 9128a4b2466259956a56fbc953e1be050faad319 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 22 Apr 2012 18:45:55 +0300 Subject: Improve keyboard handling in create character dialog. --- src/gui/charcreatedialog.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/gui/charcreatedialog.cpp') diff --git a/src/gui/charcreatedialog.cpp b/src/gui/charcreatedialog.cpp index 864ddf0b6..db6916a62 100644 --- a/src/gui/charcreatedialog.cpp +++ b/src/gui/charcreatedialog.cpp @@ -24,6 +24,8 @@ #include "client.h" #include "game.h" +#include "keydata.h" +#include "keyevent.h" #include "localplayer.h" #include "main.h" #include "units.h" @@ -230,6 +232,8 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot): updateRace(); updatePlayer(); + + addKeyListener(this); } CharCreateDialog::~CharCreateDialog() @@ -548,3 +552,19 @@ void CharCreateDialog::updatePlayer() mPlayer->setAction(actions[mAction]); } } + +void CharCreateDialog::keyPressed(gcn::KeyEvent &keyEvent) +{ + int actionId = static_cast(&keyEvent)->getActionId(); + switch (actionId) + { + case Input::KEY_GUI_CANCEL: + keyEvent.consume(); + action(gcn::ActionEvent(mCancelButton, + mCancelButton->getActionEventId())); + break; + + default: + break; + } +} -- cgit v1.2.3-60-g2f50