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/listbox.cpp | |
parent | 23f87c10db7e6b149e9e1f351e1a82516c545df7 (diff) | |
download | manaplus-0b7e752bd177c90a05ca752fa31810f9e34c432c.tar.gz manaplus-0b7e752bd177c90a05ca752fa31810f9e34c432c.tar.bz2 manaplus-0b7e752bd177c90a05ca752fa31810f9e34c432c.tar.xz manaplus-0b7e752bd177c90a05ca752fa31810f9e34c432c.zip |
Dehardcode keys in gui widgets.
Add new tab with keys settings in input settings tab.
Diffstat (limited to 'src/gui/widgets/listbox.cpp')
-rw-r--r-- | src/gui/widgets/listbox.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp index 2944c5be6..267f2c8cc 100644 --- a/src/gui/widgets/listbox.cpp +++ b/src/gui/widgets/listbox.cpp @@ -24,6 +24,8 @@ #include "client.h" #include "configuration.h" +#include "keyevent.h" +#include "keydata.h" #include "gui/palette.h" #include "gui/sdlinput.h" @@ -88,16 +90,16 @@ void ListBox::draw(gcn::Graphics *graphics) } } -void ListBox::keyPressed(gcn::KeyEvent& keyEvent) +void ListBox::keyPressed(gcn::KeyEvent &keyEvent) { - gcn::Key key = keyEvent.getKey(); + int action = static_cast<KeyEvent*>(&keyEvent)->getActionId(); - if (key.getValue() == Key::ENTER || key.getValue() == Key::SPACE) + if (action == Input::KEY_GUI_SELECT) { distributeActionEvent(); keyEvent.consume(); } - else if (key.getValue() == Key::UP) + else if (action == Input::KEY_GUI_UP) { if (getSelected() > 0) setSelected(mSelected - 1); @@ -105,7 +107,7 @@ void ListBox::keyPressed(gcn::KeyEvent& keyEvent) setSelected(getListModel()->getNumberOfElements() - 1); keyEvent.consume(); } - else if (key.getValue() == Key::DOWN) + else if (action == Input::KEY_GUI_DOWN) { if (getSelected() < (getListModel()->getNumberOfElements() - 1)) { @@ -118,12 +120,12 @@ void ListBox::keyPressed(gcn::KeyEvent& keyEvent) } keyEvent.consume(); } - else if (key.getValue() == Key::HOME) + else if (action == Input::KEY_GUI_HOME) { setSelected(0); keyEvent.consume(); } - else if (key.getValue() == Key::END && getListModel()) + else if (action == Input::KEY_GUI_END && getListModel()) { setSelected(getListModel()->getNumberOfElements() - 1); keyEvent.consume(); |