diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-04-19 23:48:29 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-04-19 23:48:29 +0300 |
commit | 0b7e752bd177c90a05ca752fa31810f9e34c432c (patch) | |
tree | db1809a48faf051af11c94058e8f126c9e9ef1ab /src/gui/widgets/dropdown.cpp | |
parent | 23f87c10db7e6b149e9e1f351e1a82516c545df7 (diff) | |
download | plus-0b7e752bd177c90a05ca752fa31810f9e34c432c.tar.gz plus-0b7e752bd177c90a05ca752fa31810f9e34c432c.tar.bz2 plus-0b7e752bd177c90a05ca752fa31810f9e34c432c.tar.xz plus-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.cpp | 48 |
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(); } |