summaryrefslogtreecommitdiff
path: root/src/gui/widgets/dropdown.cpp
diff options
context:
space:
mode:
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();
}