summaryrefslogtreecommitdiff
path: root/src/gui/widgets/dropdown.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-04-19 23:48:29 +0300
committerAndrei Karas <akaras@inbox.ru>2012-04-19 23:48:29 +0300
commit0b7e752bd177c90a05ca752fa31810f9e34c432c (patch)
treedb1809a48faf051af11c94058e8f126c9e9ef1ab /src/gui/widgets/dropdown.cpp
parent23f87c10db7e6b149e9e1f351e1a82516c545df7 (diff)
downloadmv-0b7e752bd177c90a05ca752fa31810f9e34c432c.tar.gz
mv-0b7e752bd177c90a05ca752fa31810f9e34c432c.tar.bz2
mv-0b7e752bd177c90a05ca752fa31810f9e34c432c.tar.xz
mv-0b7e752bd177c90a05ca752fa31810f9e34c432c.zip
Dehardcode keys in gui widgets.
Add new tab with keys settings in input settings tab.
Diffstat (limited to 'src/gui/widgets/dropdown.cpp')
-rw-r--r--src/gui/widgets/dropdown.cpp48
1 files changed, 34 insertions, 14 deletions
diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp
index 91c983f26..5ecfba84d 100644
--- a/src/gui/widgets/dropdown.cpp
+++ b/src/gui/widgets/dropdown.cpp
@@ -25,6 +25,8 @@
#include "client.h"
#include "configuration.h"
#include "graphics.h"
+#include "keydata.h"
+#include "keyevent.h"
#include "gui/palette.h"
#include "gui/sdlinput.h"
@@ -233,20 +235,38 @@ void DropDown::keyPressed(gcn::KeyEvent& keyEvent)
if (keyEvent.isConsumed())
return;
- gcn::Key key = keyEvent.getKey();
-
- if (key.getValue() == Key::ENTER || key.getValue() == Key::SPACE)
- dropDown();
- else if (key.getValue() == Key::UP)
- setSelected(getSelected() - 1);
- else if (key.getValue() == Key::DOWN)
- setSelected(getSelected() + 1);
- else if (key.getValue() == Key::HOME)
- setSelected(0);
- else if (key.getValue() == Key::END && mListBox->getListModel())
- setSelected(mListBox->getListModel()->getNumberOfElements() - 1);
- else
- return;
+ int actionId = static_cast<KeyEvent*>(&keyEvent)->getActionId();
+
+ switch(actionId)
+ {
+ case Input::KEY_GUI_SELECT:
+ case Input::KEY_GUI_SELECT2:
+ dropDown();
+ break;
+
+ case Input::KEY_GUI_UP:
+ setSelected(getSelected() - 1);
+ break;
+
+ case Input::KEY_GUI_DOWN:
+ setSelected(getSelected() + 1);
+ break;
+
+ case Input::KEY_GUI_HOME:
+ setSelected(0);
+ break;
+
+ case Input::KEY_GUI_END:
+ if (mListBox->getListModel())
+ {
+ setSelected(mListBox->getListModel()->
+ getNumberOfElements() - 1);
+ }
+ break;
+
+ default:
+ return;
+ }
keyEvent.consume();
}