summaryrefslogtreecommitdiff
path: root/src/gui/widgets/dropdown.cpp
diff options
context:
space:
mode:
authorTametomo <irarice@gmail.com>2009-04-20 02:14:19 -0600
committerBjørn Lindeijer <bjorn@lindeijer.nl>2009-04-20 22:23:44 +0200
commit899f8e62b670726c61f8105f2226de448b180a19 (patch)
tree26ded058d794f2eb5345fbc5f2819b68d152d6a4 /src/gui/widgets/dropdown.cpp
parent4244e0f4b1cb1973ed2919dfbb4ce5beaf3eff96 (diff)
downloadmana-899f8e62b670726c61f8105f2226de448b180a19.tar.gz
mana-899f8e62b670726c61f8105f2226de448b180a19.tar.bz2
mana-899f8e62b670726c61f8105f2226de448b180a19.tar.xz
mana-899f8e62b670726c61f8105f2226de448b180a19.zip
Fixed key handling in dropdowns when the dropdown portion isn't visible.
Signed-off-by: Tametomo <irarice@gmail.com> Signed-off-by: Bjørn Lindeijer <bjorn@lindeijer.nl>
Diffstat (limited to 'src/gui/widgets/dropdown.cpp')
-rw-r--r--src/gui/widgets/dropdown.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp
index 8688e07d..491e6396 100644
--- a/src/gui/widgets/dropdown.cpp
+++ b/src/gui/widgets/dropdown.cpp
@@ -25,6 +25,7 @@
#include "gui/widgets/scrollarea.h"
#include "gui/palette.h"
+#include "gui/sdlinput.h"
#include "configuration.h"
#include "graphics.h"
@@ -188,3 +189,48 @@ void DropDown::drawButton(gcn::Graphics *graphics)
static_cast<Graphics*>(graphics)->
drawImage(buttons[mDroppedDown][mPushed], getWidth() - height + 2, 1);
}
+
+// -- KeyListener notifications
+void DropDown::keyPressed(gcn::KeyEvent& keyEvent)
+{
+ gcn::Key key = keyEvent.getKey();
+
+ if (key.getValue() == Key::ENTER || key.getValue() == Key::SPACE)
+ {
+ if (!mDroppedDown)
+ dropDown();
+ keyEvent.consume();
+ }
+ else if (key.getValue() == Key::UP)
+ {
+ setSelected(getSelected() - 1);
+ keyEvent.consume();
+ }
+ else if (key.getValue() == Key::DOWN)
+ {
+ setSelected(getSelected() + 1);
+ keyEvent.consume();
+ }
+ else if (key.getValue() == Key::HOME)
+ {
+ setSelected(0);
+ keyEvent.consume();
+ }
+ else if (key.getValue() == Key::END)
+ {
+ setSelected(mListBox->getListModel()->getNumberOfElements() - 1);
+ keyEvent.consume();
+ }
+}
+
+void DropDown::mouseWheelMovedUp(gcn::MouseEvent& mouseEvent)
+{
+ setSelected(getSelected() - 1);
+ mouseEvent.consume();
+}
+
+void DropDown::mouseWheelMovedDown(gcn::MouseEvent& mouseEvent)
+{
+ setSelected(getSelected() + 1);
+ mouseEvent.consume();
+}